今天在远程服务器上安装MySQL,出现了各种错误,大致错误信息如下:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
ubuntu@VM-5-212-ubuntu:/etc/init.d$ service mysqld status
● mysqld.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
查找了各种方法,很多说是my.cnf配置文件的问题,找了很久找到了这个文件,发现这个文件里面竟然只有注释,没有他们所说的内容,无从改起。实在折腾得没办法加上文件残缺,考虑重装:
sudo apt-get remove mysql-server
sudo apt-get autoremove mysql-server
sudo apt-get remove mysql-common //这个很重要
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P //清理残留数据
sudo apt-get update
sudo apt-get install mysql-server //重装