10多年的信息工作,随时记录心得和资料,希望能结识更多的朋友
分类: 系统运维
2017-01-05 15:21:33
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
|