Recently, an error occurred while starting MySQL. The error message is as follows: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Troubleshooting process 1. First check Also check if it's a permissions issue. 2. Make sure your mysql.sock is in that location. mysql -u yourmysqlusername -p -S /var/lib/mysql/mysql.sock 3. Try: 4. If it is a permission problem, change the permission first [root@localhost ~]# /etc/init.d/mysqld start Start MySQL: [ OK ] [root@localhost ~]# mysql -u root -p ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) The reason is the access permission problem of /var/lib/mysql. shell> chown -R mysql:mysql /var/lib/mysql Then start the server shell> /etc/init.d/mysql start After the server starts normally, check /var/lib/mysql and automatically generate the mysql.sock file. But my problem is still not solved. The problem is finally solved: Method: Modify /etc/my.conf: [mysqld] datadir=/usr/local/mysql/data socket=/var/lib/mysql/mysql.sock [mysql.server] user=mysql basedir=/usr/local/mysql If there is not currently a section called [client], add one at the bottom of the file and copy the socket= line under the [mysqld] section such as: [client] socket=/var/lib/mysql/mysql.sock I still found that the same thing happened. I ran Problem solved. Summarize Well, that’s all for this article. I hope that the content of this article can be helpful to your study or use of MySQL. If you have any questions, please leave a message to communicate. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
>>: Best tools for taking screenshots and editing them in Linux
Copy code The code is as follows: <!DOCTYPE ht...
Because some dependencies of opencv could not be ...
The meaning of key_len In MySQL, you can use expl...
Recently, when I installed MySQL in Docker, I fou...
background go-fastdfs is a distributed file syste...
Preface: The Linux host is relatively easy to han...
Brief Description This is a CSS3 cool 3D cube pre...
1. Changes in MySQL's default storage engine ...
Preface In actual development, business requireme...
Data URI Data URI is a scheme defined by RFC 2397...
Introduction to border properties border property...
The installation and configuration method of MySQ...
1. Use of alias The alias command is used to set ...
Preface The electricity in my residence has been ...
This article shares the specific code of JavaScri...