1、更新系统软件依赖
sudo apt update && sudo apt upgrade
2、删除/var/lib/mysql 和 /etc/mysql
sudo rm /var/lib/mysql/ -R
sudo rm /etc/mysql/ -R
sudo apt-get autoremove mysql* --purge
sudo apt-get remove apparmor
sudo apt-get install mysql-server mysql-common
3、配置MySQL
(1)通过 alter user 'root'@'localhost' identified with mysql_native_password by 'Ab123456'; 命令来修改密码。
(2)增加远程连接数据账号。通过 create user 'root'@'%' identified with mysql_native_password by 'Abc123456';
(3)授权新建的远程账号。grant all privileges on *.* to 'root'@'%' with grant option;
(4)刷新权限。flush privileges;