MySQL Unable to start the problem solution: Mysql.sock Restart does not automatically generate, Mysqld_safe start error

Source: Internet
Author: User
Tags file permissions

MySQL does not start the problem solution: Mysql.sock Restart is not automatically generated, Mysqld_safe start error-Superluckytime 2013-08-03 11:55:00 Blog Park-Original essence Area Originalhttp://www.cnblogs.com/super-lucky/p/superlucky.html ThemesMySQL

I am still a rookie, below is my experience, can solve some problems, there is wrong place, please treatise.

Mine is centos6.3+mysql5.1.57.

After restarting the server, using the > Mysql-u root-p login is the following error:

ERROR 2002 (HY000): Can ' t connect to 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 cannot start.

I started troubleshooting, and first I found out that/tmp/mysql.sock didn't exist.

>vim/etc/my.cnf

Socket=/var/lib/mysql/mysql. Sock

/var/lib/mysql/mysql. Sock also does not exist

>find/-name Mysql.sock

The Mysql.sock file is missing because the display is empty and the Mysql.sock file is not queried.

I see someone on the internet saying that mysql.sock socket file can be simply re-created by restarting the server to get it,

>init 6 Restart command

After restarting, the error is still the same, there is no change, mysql.sock Restart the server is not automatically generated.

Next learn that Mysql.sock is a temporary file, it will be generated automatically when MySQL starts, my server does not start, naturally there is no Mysql.sock file.

I tried secure 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 from .../mysql/var
Stopping server from PID file .... pid

130802 15:17:11 Mysqld Ended

In the case of various command attempts, I started the biggest harvest----learned to look at the error log.

In the error log, the reason for startup failure is very obvious, file './mysql-bin. 000004 ' not found,failed to open!

MySQL opens the Bin log feature to see if the file is present in the root of the database 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]

It's been successfully started! ~

At this point the Mysql.sock file appears, in/var/lib/mysql/mysql. Sock. As shown, files that begin 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

The solution to this error is simple, because/tmp/mysql.sock does not exist, in such a way:

>ln-s/var/lib/mysql/mysql. Sock/tmp/mysql. Sock

Files that start with "l" are soft link files. Or you can fix it by modifying the/etc/my.cnf file.

Successfully solved! ~

It's such a problem that has been killing me for so long that the error log makes it invisible. Viewing the error log can clarify the problem, rather than blindly looking for the wrong thing as I did before.

As the saying goes, to give people to fish than to teach people to fishing, learn to view the log, you can also be convenient and quick to solve the problem.

Mistakes make people progress, I struggled with this error for four hours, on the Linux "all documents" This sentence has a deeper understanding of my Learning File system Management (directory tree) has a great help, let my mind really from the Windows operating system to the Linux system. And finally solve the problem, a sense of accomplishment, I like this feeling.

Hope to read you have some help, thank you! ~

MySQL Unable to start the problem solution: Mysql.sock Restart does not automatically generate, Mysqld_safe start error

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.