Mine is centos6.3+mysql5.1.57. After restarting the server, using the > Mysql-u root-p Landing is the following error:
ERROR 2002 (HY000): Can ' t connect to the local MySQL server through socket '/tmp/mysql.sock ' (2)
So, I'm prosecuting MySQL state:
>/etc/rc.d/init.d/mysqld Status
Show stop, not running.
>/etc/rc.d/init.d/mysqld restart
Stopping mysqld: [OK]
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
>ps-ef | grep MySQL
Root 28221 27474 0 14:18 pts/0 00:00:00 grep MySQL only this one
At this point, I can confirm that MySQL does not start.
I started to/tmp/mysql.sock, and first I found out that there was no
>vim/etc/my.cnf
Socket=/var/lib/mysql/mysql. Sock
/var/lib/mysql/mysql Sock also does not exist.
>find/-name Mysql.sock
The display is empty, the Mysql.sock file is not queried, and the Mysql.sock file is missing.
I see someone on the internet saying Mysql.sock sockets file can be simply recreated by restarting the server to get it,
>init 6 reboot Command
The error was found after the reboot, and without any changes, the Mysql.sock reboot server was not automatically generated.
Next to understand that Mysql.sock is a temporary file, in the MySQL startup will automatically generate, my server did not start, naturally there is no mysql.sock files.
I tried safe boot mode, Mysqld_safe tried to find the server and database through the working directory, but Mysqld_safe failed.
>mysqld_safe &
Starting mysqld daemon with databases .../mysql/var
Stopping server from PID file .... pid
130802 15:17:11 Mysqld Ended
Various command attempts to invalidate the case, I began the biggest harvest----learn to read the error log.
In the error log, the reason for startup failure is extremely obvious, file './mysql-bin. 000004 ' not found,failed to open!
MySQL opens the Bin log feature to the database root to see if the file exists and may be a problem with file permissions.
>chown-r Mysql:mysql/....../mysql/var
>mysqld_safe &
>/etc/rc.d/init.d/mysqld restart
Stopping mysqld: [OK]
Starting mysqld: [OK]
Successfully launched the!~
At this point the Mysql.sock file appears, in/var/lib/mysql/mysql. Sock. As the following illustration shows, files that start with "s" are socket files.
> Mysql-u root-p
ERROR 2002 (HY000): Can ' t connect to the local MySQL server through socket '/tmp/mysql.sock ' (2)
/tmp/mysql.sock
The solution to this error is simple, because/tmp/mysql.sock does not exist, in this way:
>ln-s/var/lib/mysql/mysql. Sock/tmp/mysql Sock
A file that starts with "L" is a soft link file. Or you can modify the/etc/my.cnf file to fix it.
Successfully solved the!~
It was such a question that had plagued me for so long that the error log kept it hidden. Looking at the error log makes it clear where the problem is, not as blind as I did before.
As the saying goes, teach people to fish than to teach people to fishing, learn to check the log, you can easily and quickly solve the problem.
Mistakes make people progress, I have struggled with this mistake for four hours, and I have a better understanding of Linux's "All Files" sentence, and have a great help in learning File system management (the directory tree) so that my mind really moves from the Windows operating system to Linux. And finally solve the problem, a sense of achievement, I like this feeling.