全新安装 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
知道为什么会这样吗?以及如何解决
你得到的错误是:
2 是 ENOENT,或者没有这样的文件或目录。这意味着套接字不存在。原因是 MariaDB 没有运行。您需要在运行之前启动 MariaDB
mysql_secure_installation
。