以MySQL- 5.7.18爲例:mysql
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 ,效果圖:sql
安裝MySQL:spa
sudo apt-get install mysql-server sudo apt-get install mysql-client sudo apt-get install libmysqlclient-dev
啓動、關閉服務和查看運行狀態code
sudo service mysql start
sudo service mysql stop
sudo service mysql status