Can't connect to local MySQL server through socket solution, connectmysql
Fault description:
Mysql startup error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql. sock' (2)
1. Check the mysql startup status first.
#/Etc/rc. d/init. d/mysqld status
2. Search and verify the location of mysql. sock?
# Find/-name mysql. sock
/Data/mydata/mysql. sock
Verify that the directory is correct
# Mysql-u root-p-S/Data/mydata/mysql. sock
Remarks:-S parameter socket file Verification
3. Verify that mysql. sock file permissions and users are correct?
If the permission is incorrect, change the permission first.
# Chown-R mysql: mysql/Data/mydata/mysql. sock
[Root @ localhost ~] #/Etc/init. d/mysqld start
Start MySQL: [OK]
4. permanent solution
Modify/etc/my. cnf
Add the following content to/etc/my. conf:
[Client]
Socket =/Data/mydata/mysql. sock
[Mysqld]
Socket =/Data/mydata/mysql. sock