ubuntu安装mysql 5.7

1.安装mysql

sudo apt-get install mysql-client mysql-server

2.启动

service mysqld start

3.登陆

mysql -uroot

报错Access denied for user 'root'@'localhost'

4.打开/etc/mysql/debian.conf

mysql -udebian-sys-maint -p7muZMj8yEczJkvgi

5.修改密码

update user set plugin='mysql_native_password';

update user set authentication_string=password('123456') where user='root' and host='localhost';

flush privileges;

6.重新登陆

mysql -uroot -p123456

-------------------------------------------------------------------------------------------------------------------------------------- 

删除 mysql

sudo apt-get autoremove --purge mysql-server-5.0
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
原文地址:https://www.cnblogs.com/kevin19931015/p/9206942.html