First of all, the environment: Ubuntu 14.04, installed in a apt-get way, manual installation may have a slightly different path setting.
1, after the installation of MySQL, the first time with the command line to find the Mysqld.sock file is not found, prompt:
ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock ' (2),
2, the method of the Internet is not practical, here is a simple way to solve the problem.
# sudo/etc/init.d/mysql Restart
3, Detours:
[Email protected]:/# mysql-uroot-p
Enter Password:
ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock ' (2)
[Email protected]:/opt#cd/var/run/mysqld/
[Email Protected]:/var/run/mysqld#ls
[Email protected]:/var/run/mysqld#
The inside is empty, lacks the mysql-client?
[Email protected]:/var/run/mysqld#apt-get Install mysql-client
[Email protected]:/opt#cd/var/run/mysqld/
[Email Protected]:/var/run/mysqld#ls
Or nothing, change the command to start:
[Email protected]:/var/run/mysqld#service mysqld Start
Mysqld:unrecognized Service
Find the root of the problem in:/etc/mysql/my.cnf
[Email PROTECTED]:/ETC#CD mysql/
[Email Protected]:/etc/mysql#ls
CONF.D debian.cnf Debian-start my.cnf
[Email Protected]:/etc/mysql#vim my.cnf
Here are the settings for Mysqld.sock, which is not found when MySQL follows this default setting.
If changing the path problem here can be cumbersome, use the following approach to solve the problem:
[Email protected]:/#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, is corrupt or were
notclosed cleanly.
[Email protected]:/#mysql-uroot-p
Enterpassword:
Welcometo the MySQL Monitor. Commands End With; or \g.
Yourmysql Connection ID is 43
。。。。。。
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current inputstatement.
Mysql>
OK, Fix it.
MySQL note-The simplest way to troubleshoot problems that cannot find the Mysqld.sock file