Get the App
SLTechnology News&Howtos  ›  Database  › 

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

Shulou Source: shulou.com Published: 2022-05-31 13:57:49 10月25日 Update

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!

Tags: Question content method is in link learn practical deeper it doesn't matter interest parameter practicality reality situation interlude simple operation file way time more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Apple MySQL Shulou Information Shulou Tech Info