# 查看 RPM 安裝包 rpm -qa | grep -i mysql # 輸出示例 MySQL-client-5.5.25a-1.rhel5 MySQL-server-5.5.25a-1.rhel5
service mysql stop # 正常卸載 rpm -ev MySQL-client-5.5.25a-1.rhel5 rpm -ev MySQL-server-5.5.25a-1.rhel5
# 忽略依賴 rpm -ev MySQL-client-5.5.25a-1.rhel5 --nodeps # 腳本報錯時跳過腳本 rpm -e --noscripts MySQL-client-5.5.25a-1.rhel5
find / -name mysql
/var/lib/mysql /var/lib/mysql/mysql /usr/lib64/mysql /usr/local/mysql # 源碼安裝常見路徑 /data/mysql # 自定義數據目錄
rm -rf /var/lib/mysql rm -rf /usr/lib64/mysql rm -rf /usr/local/mysql rm -rf /data/mysql
rm -f /etc/my.cnf rm -f /etc/mysql/my.cnf
rm -f /etc/init.d/mysqld rm -f /etc/rc.d/init.d/mysqld # 檢查 /etc/profile.d/ 是否有 mysql 相關腳本
userdel mysql groupdel mysql
rpm -qa | grep -i mysql # 無輸出 find / -name mysql 2>/dev/null | head -20 # 僅剩無關文件 which mysql # 無輸出 mysql --version # command not found
/var/log/mysqld.log、/var/log/mysql/ 日誌目錄/tmp/mysql.sock、/var/run/mysqld/ Socket 文件/root/.mysql_history 歷史命令/usr/lib/systemd/system/mysqld.service徹底卸載核心在於「包管理器卸載 + 文件系統掃描刪除 + 用戶組清理」。RPM 安裝優先用 rpm -e --nodeps;源碼安裝需手動追蹤 --prefix 指定的安裝路徑與自定義數據目錄。卸載後建議重啟系統驗證無殘留進程佔用端口。