Mysql连接提示:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
如下:
- [root@cacti01 ~]# mysql
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
- [root@cacti01 ~]# mysql -h localhost -p -u root
- Enter password:
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
而那个文件是压根不存在的:
- [root@cacti01 ~]# more /var/lib/mysql/mysql.sock
- /var/lib/mysql/mysql.sock: No such device or address
经查为mysqld服务没启动,启动后登录正常。
- [root@cacti01 ~]# service mysqld start
- Starting mysqld: [ OK ]
- [root@cacti01 ~]# mysql
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 2
- Server version: 5.1.61 Source distribution
- Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- mysql>
状态查询:
- [root@cacti01 ~]# service mysqld status
- mysqld (pid 16211) is running...
正常后上面的那个文件还是不存在的,所以跟那个没有关系。