1. 程式人生 > >{linux} Can't connect to local MySQL server through socket '/tmp/mysql.sock'

{linux} Can't connect to local MySQL server through socket '/tmp/mysql.sock'

安裝mysql成功後,登陸mysql -uroot -p輸入密碼發生

mysql -uroot -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

兩個可能1.確實連線找不到該mysql.sock 2.初次安裝密碼問題

[mysqld]
#skip-grant-tables  2,問題解決方式 免密登陸

datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
**socket=/tmp/mysql.sock**   將配置修改
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

~                                                                                                                        
~                                                                                                                        
~                                                                                                                        
~                                                                                                                        
"/etc/my.cnf" 22L, 614C