Mysql

mariadb v15.1 不安裝socket / Centos 7

  • December 19, 2016

全新安裝 CentOS 7

# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

yum -y install mariadb-server mariadb

# mysql -V
mysql  Ver 15.1 Distrib 5.5.52-MariaDB, for Linux (x86_64) using readline 5.1

/usr/bin/mysql_secure_installation


Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Enter current password for root (enter for none):

mysqladmin password newpassword

mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!

檢查 /var/lib/mysql/

la /var/lib/mysql/

# ls /var/lib/mysql/
aria_log.00000001  aria_log_control  ibdata1  ib_logfile0  ib_logfile1  mysql  performance_schema  test

知道為什麼會這樣嗎?以及如何解決

你得到的錯誤是:

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

2 是 ENOENT,或者沒有這樣的文件或目錄。這意味著套接字不存在。原因是 MariaDB 沒有執行。您需要在執行之前啟動 MariaDB mysql_secure_installation

systemctl start mariadb

引用自:https://serverfault.com/questions/821654