How to troubleshoot Mysql installation

Source: Internet
Author: User

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 mysql.sock Socket File you can simply re-create it by restarting the server,

>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 Safe Boot mode, mysqld_safe tried to find the server and database through the working directory, but mysqld_safe is still a failure.

      >mysqld_safe &
         starting mysqld daemon with databases from .../mysql/var 
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! ~

Transferred from:http://www.cnblogs.com/super-lucky/p/superlucky.html

How to troubleshoot Mysql installation

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.