ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

centos7.5 连接数据库失败

问题:

[root@jumpserver ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

解决办法:

[root@jumpserver ~]# ps -A|grep -i  mysql
 13284 ?        00:00:00 mysqld_safe
 13422 ?        00:01:33 mysqld
[root@jumpserver ~]# kill 13284 
[root@jumpserver ~]# kill 13422
[root@jumpserver ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@jumpserver ~]# ps -A|grep -i  mysql
[root@jumpserver ~]# systemctl start mariadb
[root@jumpserver ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@jumpserver ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.