Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of ERROR 2002 (HY000) error reporting in MySQL

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "how to solve the problem of ERROR 2002 (HY000) error reporting in MySQL". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to solve the problem of ERROR 2002 (HY000) error reporting in MySQL.

[root@testmysql bin] #. / mysql

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

Solution:

Because the default mysql.sock of mysql is / usr/local/mysql/data/mysql.sock, but the linux system always goes to / tmp/mysql.sock to find it, so it will report an error.

1. Specify the mysql channel directly

As far as I know (ps: I am a rookie, please correct), the old version is: / var/lib/mysql/mysql.sock

In the new version, the default is / usr/local/mysql/data/mysql.sock. Specifically, you can check the my.cnf file.

[root@testmysql bin] #. / mysql-socket=/usr/local/mysql/data/mysql.sock

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 1

Server version: 5.6.4-m7 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

Mysql >

two。 Create a symbolic connection:

Add soft connections to mysql.sock (equivalent to shortcuts in windows).

Ln-s / var/lib/mysql/mysql.sock / tmp/mysql.sock

Eg:

Root@localhost ~] # mysql

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

[root@testmysql bin] # ln-s / var/lib/mysql/mysql.sock / tmp/mysql.sock

Interlude: it is possible that you have the following situation when you establish a connection

[root@testmysql bin] # ln-vs / usr/local/mysql/data/mysql.sock / tmp/mysql.sock

Ln: creating symbolic link `/ tmp/mysql.sock': File exists

It doesn't matter, just add the-f parameter. The main process of-f: first delete the soft link dd with the same name, and then create a hard link dd

[root@testmysql bin] # ln-f / usr/local/mysql/data/mysql.sock / tmp/mysql.sock

[root@testmysql bin] #. / mysql

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 1

Server version: 5.6.4-m7 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

Mysql >

At this point, I believe you have a deeper understanding of "how to solve the problem of ERROR 2002 (HY000) error reporting in MySQL". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report