ERROR 2002 (HY000) : Can ‘t connect to local MySQL server through socket’/var/run/mysqld/mysqld. (2) the sock ‘
The server encountered a familiar problem today
Input:
#mysql -u root -p
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
Then he searched the Internet for answers
I’m going to try each of the methods that you’ve given me
Plan 1
#ps -A|grep mysql
Display similar to:
1829 ? 00:00:00 mysqld_safe
1876 ? 00:00:31 mysqld
#kill -9 1829
#kill -9 1876
#/etc/init.d/mysqld restart
#mysql -u root -p
His problem is solved, mine is not solved!
keep looking for
Scheme 2
Check the/etc/rc. D/init. D/mysqld status to see if the mysql has already started.
see if other permissions problems.
— — — — — — — — — — — — — —
[root@localhost beinan]#chown -R mysql:mysql /var/lib/mysql
[root@localhost beinan]# /etc/init.d/mysqld start
Start MySQL: [OK]
[root@localhost lib]# mysqladmin -uroot password ‘123456’
[root@localhost lib]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 3 to server version: 4.1.11
Type ‘help;’ or ‘/h’ for help. Type ‘/c’ to clear the buffe
His was solved, and my troubles continued, and my search continued
Scheme 3
problem solved, but max_connections=1000. He said too much, then changed it to 500, but the problem was solved.
Still won’t do
Plan 4
/var/lib/mysql All file permissions change to mysql.mysql
No, no
Scheme 5
abstract: Solve by mysql. The problem of the sock to connect mysql main hint is that the problem can’t ‘/ TMP/mysql. The sock’ connected to the server, and PHP standard configuration is used ‘/ TMP/mysql. The sock, but some mysql installation method will mysql. The sock in/var/lib/mysql. Where the sock or other, you can modify the/etc/my CNF file to correct it, open the file, you can see the following things:
[mysqld]
socket=/var/lib/mysql .sock
A change would be fine, but it could also cause other problems, such as the mysql program can’t be connected. Add one more point:
[mysql ]
socket=/tmp/mysql .sock
Or you can modify the configuration in php.ini to make PHP use another mysql.sock, and you can find this for yourself
or you can do it this way:
ln -s /var/lib/mysql /mysql .sock /tmp/mysql .sock
It worked. That was ln-s /var/lib/mysql. sock/TMP/mysql. sock
OK!
Solution to MySQL. Sock loss problem under MySQL 6
[ubuntu, Linux, mysqld.sock]
MySQL. Sock loss is generally caused by inconsistent configuration files. The solution:
It is judged that ordinary people did not switch to mysql user when solving the failure, which caused some permission problems. Therefore, they could not create mysql authorization table, so they could not create/TMP/mysqlm. sock and Hostname. pid files. Therefore, the summary solution is as follows (note: using root is also acceptable) :
#su mysql
$/usr/local/bin/mysql_install_db //Reconstruction authorization table
$/usr/local/bin/mysqld_safe &
$/usr/local/bin/mysql //Test
mysq>bye;
$
The file has been solved, and the new/TMP /mysql.sock and hostname.pid
have been generated.
Share source address: https://blog.csdn.net/thanklife/article/details/69225724
The fifth plan, which I borrowed from the Internet, was not successful for me. Only the sixth one succeeded!
Read More:
- [Solved] ERROR 2002 (HY000): Can’t connect to local MySQL server through socket’/var/lib/mysql/mysql.sock’ (2)
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’
- How to Solve can‘t connect to local mysql server through socket ‘/var/lib/mysql/mysql.sock‘
- [Solved] MYSQL Command Execute Error: Can ‘t connect to local MySQL server through socket ‘/tmp/mysql.sock ‘(2) “
- MySql Install Error: Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘
- MYSQL8 Startup Error: mysqld_safe error: log-error set to ‘/var/log/mariadb/mariadb.log‘
- Centos7 Initialize mysql Error: Could not open file ‘/usr/local/mysql/log/mysqld.log‘ for error logging: Per
- How to Fix MySQL ERROR 1130 (HY000): Host ‘XXXX’ is not allowed to connect to this MySQL server
- Ubuntu ERROR 2003 (HY000): Can’t connect to MySQL server on ‘127.0.0.1’ (111)
- [Solved] MySQL Startup Error: Job for mysqld.service failed because the control process exited with error code
- MYSQL Enter password:ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost:3306‘
- [Solved] CentOS installs MySQL and starts MySQL with error 2002 (HY000)
- ERROR: mysqld failed while attempting to check config [How to Solve]
- How to Solve mysqld — console command error
- host ‘‘ is not allowed to connect to this mysql server Connect MYSQL Error
- [Solved] Job for mysqld.service failed because the control process exited with error code
- Remote connection to MySQL database error: is not allowed to connect to this MYSQL server solution
- mac brew install mysql ‘/tmp/mysql.sock’ (2) [How to Solve]
- [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
- [Solved] mysqldump Command Error: Got error: 2002: “Can‘t connect to server on ‘127.0.0.1‘ (36)“ when trying to connect