1.卸载mysql
apt-get autoremove --purge mysql-server-版本号
apt-get autoremove mysql-server
apt-get remove mysql-common
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
2.安装
$ sudo apt-get install mysql-server-5.7
sudo vi /etc/mysql/debian.cnf
// 修改用户名密码
user = debian-sys-maint
password = 63vIY3PtyKh10cmZ
sudo service mysql restart
3.测试登陆
mysql -h 127.0.0.1 -u debian-sys-maint -p
4.错误
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
解决办法:sock位置不对,需要做一个软连接
find / -name "*.sock"
ln -s /run/mysqld/mysqld.sock /var/lib/mysql/mysql.sock
https://www.cnblogs.com/Lam7/p/6090975.html