Fault description: mysql startup error: ERROR2002 (HY000): Can 'tconnecttolocalmysqlserverthroughsocket 'varlibmysqlmysqlsock '(2) 1. check mysql startup status etcrcdinitdmysqld 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