The binary installation mysql reports the following error
[[email protected] 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:
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’
- [Solved] CentOS installs MySQL and starts MySQL with error 2002 (HY000)
- [Solved] ERROR 2002 (HY000): Can’t connect to local MySQL server through socket’/var/lib/mysql/mysql.sock’ (2)
- MySql Warning: The server quit without updating PID file error
- MYSQL8 Startup Error: mysqld_safe error: log-error set to ‘/var/log/mariadb/mariadb.log‘
- [Solved] mariadb Startup Error: Job for mariadb.service failed because the control process exited with error code.
- [Solved] MYSQL Command Execute Error: Can ‘t connect to local MySQL server through socket ‘/tmp/mysql.sock ‘(2) “
- 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 Install Error: Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘
- [Solved] Starting MySQL… ERROR The server quit without updating PID file
- MySQL character set error resolution: err=Error 3988: Conversion from collation utf8mb4_unicode_ci into utf8_general_ci impo
- MYSQL 5.7 Error Code: 1290. The MySQL server is running with the –secure-file-priv option so it..
- MYSQL Error: Can‘t find error-message file [How to Solve]
- [Solved] mysqldump Command Error: Got error: 2002: “Can‘t connect to server on ‘127.0.0.1‘ (36)“ when trying to connect
- How to Solve MYSQL Error: Failed to start MySQL 8.0 database server
- [Solved] ERROR: child process failed, exited with error number 14 (error number 1, error number 100)
- Mysql ERROR 1067: Invalid default value for ‘date’ [How to Solve]
- How to Solve mysqld — console command error
- How to Fix MySQL ERROR 1130 (HY000): Host ‘XXXX’ is not allowed to connect to this MySQL server