Home  >  Article  >  Database  >  What is the 2002 error of mysql?

What is the 2002 error of mysql?

WBOY
WBOYOriginal
2022-08-31 17:04:3912519browse

In mysql, the 2022 error refers to the fact that the socket is not specified during compilation, so the default value is still used when the mysql command is connected. Because the socket location has changed and the mysql command does not know it, it appears. For such errors, you can modify the "/etc/my.cnf" file to resolve the error.

What is the 2002 error of mysql?

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

What is the 2002 error in mysql?

First reproduce the problem phenomenon, the error message is as follows:

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

What is the 2002 error of mysql?

##Error analysis, the official website roughly means It means that the socket was not specified during compilation, so the mysql command still used the default value (/tmp/mysql.sock) when connecting. Because the socket location has changed and the mysql command does not know it, such an error occurred

What is the 2002 error of mysql?

The solution is to tell the mysql command where our socket file is. Modify the /etc/my.cnf file and add the following content:

[mysqld]
socket=/data/mysql5.7.24/db_test/mysql.sock
[client]
socket=/data/mysql5.7.24/db_test/mysql.sock

What is the 2002 error of mysql?

After saving, test whether you can log in normally

mysql -uroot -p

What is the 2002 error of mysql?

Another solution is to specify the socket when logging in.

The first way of writing

mysql -uroot -p --socket=/data/mysql5.7.24/db_test/mysql.sock

The second way of writing

mysql -uroot -p -S /data/mysql5.7.24/db_test/mysql.sock

Recommended learning:

mysql video tutorial

The above is the detailed content of What is the 2002 error of mysql?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn