Mysql startup exception mysql. how to solve the problem of starting mysql with sock and learn to view the Error Log: mysql. sock loss, mysqld_safe start error Reprinted from: www.cnblogs.comsuper-luckypsuperlucky.html I am still a cainiao, below is my experience, can solve some problems, there is a wrong place, please correct.
Mysql startup exception mysql. how to solve the problem of starting mysql with sock and learn to view the Error Log: mysql. sock loss, mysqld_safe start error Reprinted from: http://www.cnblogs.com/super-lucky/p/superlucky.html I am still a cainiao, below is my experience, can solve some problems, there is a wrong place, please correct.
Mysql startup exception mysql. sock
How to solve the mysql startup error, learn to view the Error Log: mysql. sock loss, mysqld_safe startup Error
Reprinted from: http://www.cnblogs.com/super-lucky/p/superlucky.html
I am still a cainiao. Here is my experience. I can solve some problems. If there is something wrong with it, please correct it.
My website is CentOS6.3 + MySQL5.1.57.
After the server is restarted, the following error occurs when you log on to mysql-u root-p:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql. sock' (2)
So I checked the mysql status:
? ? ? ?>? /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 00:00:00 pts/0 grep mysql? Only this one
At this point, I am sure mysql cannot be started.
I started troubleshooting and first found that/tmp/mysql. sock does not exist.
? ? ? ? > Vim/etc/my. cnf
? ? ? ? ?? Socket =/var/lib/mysql. sock
? ? ? ? ?? /Var/lib/mysql. sock does not exist.
? ? ? ? > Find/-name mysql. sock
? ? ? ? ? The mysql. sock file is missing because it is not found.
Some people on the Internet say that the mysql. sock socket file can be simply created by restarting the server,
? ? ? ? ?> Init 6? ? ? Restart command
? ? ? ? ? ? The error is still found after restart, and no changes have been made. mysql. sock is not automatically generated when the server is restarted.
Next, I learned that mysql. sock is a temporary file that is automatically generated when mysql is started. If my server is not started, there will naturally be no mysql. sock file.
I tried safe start mode. mysqld_safe tried to find the server and database through the working directory, but mysqld_safe still failed.
? ? ? ?> Mysqld_safe &
? ? ? ? ? Starting mysqld daemon with databases from.../mysql/var?
? ? ? ? ? STOPPING server from pid file ??....... Pid
? ? ? ? ? 130802 15:17:11 mysqld ended
When various command attempts are ineffective, I started the biggest harvest this time-learn to read error logs.
In the error log, the cause of startup failure is extremely obvious, file './mysql-bin. 000004 'not found, failed to open!
? Mysql has enabled the bin log function. Check the file in the root directory of the database, which may be caused by file permissions.
? ? ? ?> Chown-R mysql: mysql/.../mysql/var
? ? ? ?> Mysqld_safe &
? ? ? ?> /Etc/rc. d/init. d/mysqld? Restart
? ? ? ? ? Stopping mysqld: [OK]
? ? ? ? ? Starting mysqld :[? OK]
? ? Started successfully !~
? The mysql. sock file appears at/var/lib/mysql. sock. As shown in, all files starting with "s" are socket files.
? ? ? ? ? > Mysql-u root-p
? ? ? ? ? ? ? ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql. sock' (2)
/Tmp/mysql. sock
? ? ? ? ? It is easy to solve this error because/tmp/mysql. sock does not exist. Use this method:
? ? ? ? ? > Ln-s/var/lib/mysql. sock? /Tmp/mysql. sock
Files starting with "l" are soft-link files. Alternatively, you can modify the/etc/my. cnf file.
? ? Solved successfully !~
This is a problem that has plagued me for so long, and the error log makes it invisible. You can view the error log to identify the problem, rather than blindly finding the error as I did before.
As the saying goes, it is better to teach people to fish than to teach people to fish. You can learn to view logs and solve problems conveniently and quickly.
Errors make progress. I have struggled with this mistake for more than four hours and have a better understanding of the "Everything is a file" sentence in linux, it is of great help for me to learn about File System Management (directory tree), so that I can truly switch my thinking from a windows operating system to a linux system. And finally solved the problem, very sense of accomplishment, I like this feeling.
I hope it will help you read this article. Thank you !~
?