Can ' t connect to local MySQL server through socket

Source: Internet
Author: User

Solution to connect MySQL hint can ' t connect to local MySQL server through socket

September 6, 2013 aiezu Comment Read review

MySQL, mysqldump,mysqladmin,php connection MySQL service often prompts the following error:

ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/lib/<span class= ' wp_keywordlink_affiliate ' ><a href= "Http://www.aiezu.com/tag/mysql-2" title= "View all articles in MySQL" target= "_blank" >mysql</a></ Span>/mysql.sock ' (2)

1

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

This is due to the mysql.sock location of the socket file that modifies the MySQL service, which is caused by the inability to connect to the MySQL service via the MySQL socket file, the following are the specific workarounds:
1. View the location of the socket file for the MySQL service:
The location of the MySQL socket file is set in/etc/my.cnf, and the CAT/ETC/MY.CNF content is as follows:

[Mysqld] Datadir=/storage/db/mysql socket=/storage/db/mysql/mysql.sock user=mysql

1

2

3

4

[mysqld]

DataDir = / Storage / DB / MySQL

Socket = / Storage / DB / MySQL / MySQL . sock

User = MySQL

Where the socket is equal to the location of the socket file, we just modify the my.cnf file, tell MySQL,mysqldump,mysqladmin The MySQL service socket location is available.

2. Modify the My.cnf file:
Add the following in the/etc/my.cnf file and restart the MYSQLS service to resolve the Mysql,mysqldump,mysqladmin "can" T connect to local MySQL server Through socket '/var/lib/mysql/mysql.sock ' "Problem:

[Mysqld] Datadir=/storage/db/mysql socket=/storage/db/mysql/mysql.sock [MySQL] Socket=/storage/db/mysql/mysql.sock [Mysqldump] socket=/storage/db/mysql/mysql.sock [mysqladmin] Socket=/storage/db/mysql/mysql.sock

1

2

3

4

5

6

7

8

9

10

11

12

[mysqld]

DataDir = / Storage / DB / MySQL

Socket = / Storage / DB / MySQL / MySQL . sock

[mysql]

Socket = / Storage / DB / MySQL / MySQL . sock

[mysqldump]

Socket = / Storage / DB / MySQL / MySQL . sock

[mysqladmin]

Socket = / Storage / DB / MySQL / MySQL . sock


Can ' t connect to local MySQL server through socket

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.