zoukankan      html  css  js  c++  java
  • MySQL笔记-最简单的方法来解决找不到mysqld.sock文件的问题

     首先,环境:ubuntu 14.04,采用apt-get的方式安装的,手动安装可能路径设置稍有区别。

    1、安装MySQL后,用命令行首次启动时发现找不到Mysqld.sock文件,提示:

    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2),如图:

    2、网上的方法很多不实用,这里介绍一种最简单的方法来解决这个问题。

    # sudo /etc/init.d/mysql restart

     注意:个人在CentOS6.5环境下遇到此问题,此法行不通。

    3、问题的根源在:/etc/mysql/my.cnf里

    root@pc:/etc# cd mysql/

    root@pc:/etc/mysql# ls

    conf.d debian.cnf debian-start my.cnf

    root@pc:/etc/mysql# vim my.cnf

    这里有有关mysqld.sock的设置,MySQL按照这个默认设置去找时,没有找到。

    如果更改这里的路径问题会很麻烦,因此采用此法法解决。如下:
    
    root@pc:/# sudo /etc/init.d/mysql restart
    
    * Stopping MySQL database server mysqld [ OK ]
    
    * Starting MySQL database server mysqld [ OK ]
    
    * Checking for tables which need an upgrade, are corrupt or were
    
    not closed cleanly.
    
    root@pc:/# mysql -uroot -p
    
    Enter password:
    
    Welcome to the MySQL monitor. Commands end with ; or g.
    
    Your MySQL connection id is 43
    
    。。。。。。
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> 
    
    OK,解决了。
    View Code
  • 相关阅读:
    [HNOI2015]实验比较 树形dp+组合数学
    【bzoj1090】 [SCOI2003]字符串折叠
    hdu4514(非连通图的环判断与图中最长链)(树的直径)
    数据类型进阶 续1
    数据类型进阶
    二进制补码
    基本数据类型的包装类
    变量的作用域
    用变量保存多种类型的数据
    用变量简化计算
  • 原文地址:https://www.cnblogs.com/chinas/p/4378006.html
Copyright © 2011-2022 走看看