Troubleshoot MySQL Error error 2002 (HY000)

Source: Internet
Author: User
Tags mysql command line


Today, after launching the database for the new line of business, the error

[Email protected]:/usr/local/mysql/bin#./mysql

ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock ' (2)

In this record, I hope to be able to meet the problem of the brothers to provide a solution to the problem of ideas, with the idea of a step by step to troubleshoot the problem is easier, but I this question is more strange, if there is understanding of the brothers, but also generous enlighten.


Let's start by describing the environment in which this problem occurs:

Operating system: Ubuntu 14.04.5

The database version is: 5.6.39-log

The database is installed in binary installation mode


Failure phenomena

Startup error after database initialization

[Email protected]:/usr/local/mysql/bin#./mysqlerror 2002 (HY000): Can ' t connect to local MySQL server through socket '/va R/run/mysqld/mysqld.sock ' (2)

Troubleshooting

A look at whether the database process started

This error will also be reported if the database process is not started.

The process is wrong.

Two look at the configuration file of the socket file, and check the socket file exists, the permissions are correct

The location of the socket file in the configuration file is configured under/tmp/mysql.sock

But the error to go to/var/run/mysqld/mysqld.sock location to find the configuration file, the configuration file does not take effect, but such as other data files, log file directory has been in effect

See if valuable information is available in the error log

Check the error log for no related errors


Fault resolution:

The cause of the problem has not been found, to the top of the session when the database initialization after the completion of the following output,


Is it because the database was started and read the configuration files in other locations?

I started with the following command, I have specified the location of the configuration file

./mysqld_safe--DEFAULTS-FILE=/ETC/MY.CNF &

View/ETC/MYSQL/MY.CNF

Yes, I did. The location of the socket in the configuration file


After renaming a configuration file under the/etc/mysql path

[Email protected]:/etc/mysql# cd/etc/mysql/[email protected]:/etc/mysql# lsconf.d my.cnf[email protected]:/etc/mysql # MV My.cnf My.cnf_bak

Go to MySQL command line again without error, problem solved



Failure summary

You can use the following command to view the default order of the MySQL database read configuration files.

In fact, I still wonder why I have set up the configuration file bag amount location also read the other location of the configuration file? After the initialization of the database output is reflected,

This is the problem to solve is to rename the configuration files under other paths

Troubleshoot MySQL Error error 2002 (HY000)

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.