The binary installation mysql reports the following error
[root@tzPC sdb1]# mysql -v
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
It is found that /tmp/mysql.sock does not exist. The reason for this is generally due to inconsistent configuration files. If mysqld is started by mistake, mysqld_safe will clear mysql.sock once.
Solution
First check whether the current process has a surviving mysql, kill it, and then restart the database
$ ps -ef | grep mysql
$ kill -9 xxxx
$ /etc/init.d/mysqld start
If it still cannot be resolved, check whether the configuration file is correct
$ cat /etc/my.cnf
[mysqld]
user=mysql
basedir=/mnt/sdb1/mysql
datadir=/mnt/sdb1/mysql_data
socket=/tmp/mysql.sock
server_id=6
port=3306
[mysql]
socket=/tmp/mysql.sock
Use the command to find the mysql.sock file
$ find / -name mysql.sock
If not found, re-execute mysql_install_db to rebuild the authorization table
$ mysql/bin/mysql_install_db
Then execute the following command, the mysql.sock file will be there
$ mysql/bin/mysqld_safe &
$ find / -name mysql.sock
/tmp/mysql.sock
Read More:
- [Solved] MYSQL Command Execute Error: Can ‘t connect to local MySQL server through socket ‘/tmp/mysql.sock ‘(2) “
- [Solved] ERROR 2002 (HY000): Can’t connect to local MySQL server through socket’/var/lib/mysql/mysql.sock’ (2)
- MySql Install Error: Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’
- How to Solve can‘t connect to local mysql server through socket ‘/var/lib/mysql/mysql.sock‘
- mac brew install mysql ‘/tmp/mysql.sock’ (2) [How to Solve]
- MYSQL Enter password:ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost:3306‘
- 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] CentOS installs MySQL and starts MySQL with error 2002 (HY000)
- host ‘‘ is not allowed to connect to this mysql server Connect MYSQL Error
- Remote connection to MySQL database error: is not allowed to connect to this MYSQL server solution
- Mysql Flashback Warning: C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe
- How to Solve MYSQL Error: Failed to start MySQL 8.0 database server
- [Solved] MYSQL Error: ERROR! MySQL server PID file could not be found!
- MYSQL 5.7 Error Code: 1290. The MySQL server is running with the –secure-file-priv option so it..
- MySQL Install Error: MySQL error 1042: Unable to connect to any of the specified MySQL hosts
- (Fixed) workbench MySQL Error Code: 2013. Lost connection to MySQL server during query
- MYSQL Insert Data Error: check the manual that corresponds to your MySQL server version for the right syntax
- MySql Warning: The server quit without updating PID file error