标签:dev system -name x11 space 命令 ash index html
有时候,当我们使用“mysql”、“mysqladmin”、“mysqldump”等命令管理数据库时,服务器抛出类似如下错误:
1
|
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2) |
1
2
3
4
5
6
|
[root@aiezu.com ~] # mysql ERROR 2002 (HY000): Can ‘t connect to local MySQL server through socket ‘ /var/lib/mysql/mysql .sock‘ (2) [root@aiezu.com ~] # mysql -h localhost ERROR 2002 (HY000): Can ‘t connect to local MySQL server through socket ‘ /var/lib/mysql/mysql .sock‘ (2) [root@aiezu.com ~] # mysql -h 127.0.0.1 ERROR 1045 (28000): Access denied for user ‘root‘ @ ‘localhost‘ (using password: NO) |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
# 1、 端口是否打开 [root@aiezu.com ~] # lsof -i:3306 COMMAND PID USER FD TYPE DEVICE SIZE /OFF NODE NAME mysqld 12207 mysql 14u IPv4 52350 0t0 TCP *:mysql (LISTEN) # 2、mysqld服务是否正在运行 [root@aiezu.com ~] # service mysqld status mysqld (pid 4717) is running... # 3、如果mariadb,同样方法查服务是否正在运行: [root@aiezu.com ~] # service mariadb status Redirecting to /bin/systemctl status mariadb.service ● mariadb.service - MariaDB database server Loaded: loaded ( /usr/lib/systemd/system/mariadb .service; disabled; vendor preset: disabled) Active: active (running) since 四 2016-11-03 13:47:37 CST; 23min ago |
1
2
3
4
5
|
[root@aiezu.com ~] # lsof -c mysqld|grep sock$ mysqld 4717 mysql 12u unix 0xffff88010a655b80 0t0 77474827 /storage/db/mysql/mysql .sock [root@aiezu.com ~] # find / -name ‘*.sock‘ /storage/db/mysql/mysql .sock |
1
2
3
4
5
6
7
8
9
10
11
12
|
[mysqld] datadir=/storage/db/mysql socket=/storage/db/mysql/mysql.sock ...省略n行(爱E族)... [client] default-character-set=utf8 socket=/storage/db/mysql/mysql.sock [mysql] default-character-set=utf8 socket=/storage/db/mysql/mysql.sock |
1
2
3
4
5
|
[root@aiezu.com ~] # ls /var/lib/mysql/mysql.sock ls : cannot access /var/lib/mysql/mysql .sock: No such file or directory [root@aiezu.com ~] # ln -s /storage/db/mysql/mysql.sock /var/lib/mysql/mysql.sock [root@aiezu.com ~] # ls /var/lib/mysql/mysql.sock /var/lib/mysql/mysql .sock |
原文地址:http://aiezu.com/article/mysql_cant_connect_through_socket.html
(转)ERROR 2002 (HY000): Can't connect to local MySQL server through socket '***' (2)
标签:dev system -name x11 space 命令 ash index html
原文地址:http://www.cnblogs.com/mkdlf/p/6607539.html