Preface This article mainly introduces the analysis and solution of MySQL startup error: 2002. It is shared for your reference and study. Let’s take a look at the detailed introduction. 1. Fault phenomenon [root@localhost scripts]# mysql -u root ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysqld.sock' (2) 2. Fault analysis View the status of the MySQL instance [root@localhost scripts]# netstat -ntlp | grep 3306 tcp 0 0 :::3306 :::* LISTEN 13001/mysqld View my.cnf configuration about socket [root@localhost scripts]# more /etc/my.cnf |grep sock socket = /tmp/mysqld.sock This means that mysqld has claimed the correct sock file, but the client connection still looks for the sock file in the initial directory. Next, check the background log. There is an ERROR about the full query log. This is an error caused by the directory not existing and has nothing to do with the current fault. [root@localhost scripts]# more SZDB.err ............ 2014-10-11 13:17:21 13001 [Note] InnoDB: 5.6.12 started; log sequence number 1625997 /app/soft/mysql/bin/mysqld: File '/log/mysql_logs/slowquery.log' not found (Errcode: 2 - No such file or directory) 2014-10-11 13:17:21 13001 [ERROR] Could not use /log/mysql_logs/slowquery.log for logging (error 2). Turning logging off for the who le duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it. 2014-10-11 13:17:21 13001 [Note] Server hostname (bind-address): '*'; port: 3306 2014-10-11 13:17:21 13001 [Note] IPv6 is available. 2014-10-11 13:17:21 13001 [Note] - '::' resolves to '::'; 2014-10-11 13:17:21 13001 [Note] Server socket created on IP: '::'. 2014-10-11 13:17:21 13001 [Note] Event Scheduler: Loaded 0 events 2014-10-11 13:17:21 13001 [Note] /app/soft/mysql/bin/mysqld: ready for connections. Version: '5.6.12-log' socket: '/tmp/mysql.sock' port: 3306 Source distribution #Author :Leshami #Blog: http://www.linuxidc.com 3. Troubleshooting a. Solve by configuring the my.cnf mysql option socket file location Stop the mysql server first [root@localhost scripts]# systemvtl restart mysqld Shutting down MySQL. [ OK ] Modify my.cnf as follows [root@localhost scripts]# vi /etc/my.cnf [mysql] no-auto-rehash socket = /tmp/mysqld.sock #Add this line Restart mysql server [root@localhost scripts]# systemctl restart mysqld Starting MySQL..[ OK ] Connect again normally [root@localhost scripts]# mysql -uroot -p Enter password: mysql> show variables like 'version'; +---------------+------------+ | Variable_name | Value | +---------------+------------+ | version | 5.6.12-log | +---------------+------------+ b. Establish a link method for the socket file [root@SZDB mysqldata]# ln -s /tmp/mysql.sock /data/mysqldata/mysql.sock ln: creating symbolic link `/data/mysqldata/mysql.sock' to `/tmp/mysql.sock': File exists [root@SZDB mysqldata]# rm mysql.sock #The above prompt says that the file exists, so delete the previous mysql.sock file [root@SZDB mysqldata]# ln -s /tmp/mysql.sock /data/mysqldata/mysql.sock [root@SZDB mysqldata]# ls -hltr mysql.sock lrwxrwxrwx 1 root root 15 Oct 11 14:00 mysql.sock -> /tmp/mysql.sock [root@SZDB mysqldata]# mysql -uroot -p Enter password: mysql> show variables like 'socket'; +---------------+-----------------+ | Variable_name | Value | +---------------+-----------------+ | socket | /tmp/mysql.sock | +---------------+-----------------+ Summarize The above is the full content of this article. I hope that the content of this article can bring some help to your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: How to change $ to # in Linux
>>: Detailed explanation of CocosCreator project structure mechanism
How to find slow SQL statements in MySQL? This ma...
Today I would like to share with you the CSS3 tra...
In this article, I will show you how to install a...
Original text: https://dev.mysql.com/doc/refman/8...
This article shares with you a special effect mes...
Try installing via pip in a virtual environment: ...
Preface It is very simple to create a server in n...
<br />For some time, I found that many peopl...
Here are 10 HTML tags that are underused or misun...
Introduction: Lambda Probe (formerly known as Tom...
This article mainly explains the style of buttons...
This article shares with you the graphic tutorial...
Preface: In some application scenarios, we often ...
Preface Samba is a free software that implements ...
Preface The count function is used to count the r...