ubuntu16.04 彻底卸载MySQL
以MySQL- 5.7.18为例:
sudo apt-get autoremove --purge mysql-server-5.7
#sudo apt-get remove mysql-server # 没用到,已经没有mysql-server
#sudo apt-get autoremove mysql-server # 没用到,已经没有mysql-server
sudo apt-get remove mysql-common
sudo rm -rf /etc/mysql/ /var/lib/mysql #很重要
#清理残留数据
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
sudo apt autoremove
sudo apt autoreclean
执行dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P ,效果图:
安装MySQL:
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install libmysqlclient-dev
启动、关闭服务和查看运行状态
sudo service mysql start
sudo service mysql stop
sudo service mysql status