一、卸载本地 Mysql
bash
//1、查看本地mysql依赖情况
dpkg --list | grep mysql
//2.卸载mysql-common
sudo apt remove mysql-common
//3.卸载并清除mysql5.7
sudo apt autoremove --purge mysql-server-5.7
//4.清除残留数据
dpkg -l | grep ^rc| awk '{print$2}'| sudo xargs dpkg -P
//5.再次检查依赖项情况
dpkg --list | grep mysql
//6.再次执行删除
sudo apt autoremove --purge mysql-apt-config
二、安装 mysql5.7
下载MySQL apt存储库
bash
//1、使用wget下载tar包
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-server_5.7.36-1ubuntu18.04_amd64.deb-bundle.tar
//2、在目录下解压tar包
tar xvf ./mysql-server_5.7.36-1ubuntu18.04_amd64.deb-bundle.tar
//安装依赖lib包
sudo apt-get install ./libmysql*
sudo apt-get install libtinfo5
//安装客户端和服务端 ; 过程中会提示设置MySQL的密码,用户名默认root
sudo apt-get install ./mysql-community-client_5.7.36-1ubuntu18.04_amd64.deb
sudo apt-get install ./mysql-client_5.7.36-1ubuntu18.04_amd64.deb
sudo apt-get install ./mysql-community-server_5.7.36-1ubuntu18.04_amd64.deb
sudo apt-get install ./mysql-server_5.7.36-1ubuntu18.04_amd64.deb
//启动mysql ; 绿色的active表示运行中
systemctl status mysql.service
//登录Mysql
mysql -u root -p
//退出
exit
//安装成功,可以选择删除安装包
sudo rm -rf /安装包所在目录(不能是根目录)