Mac OSX完全卸载删除MySQL

时间:2022-06-01 16:42:43

1、先使用mysqldump备份数据库

2、停止MySQL,并杀掉MySQL进程

使用ps查找进程id

ps -ax | grep mysql

3、使用HomeBrew分析MySQL

brew remove mysql
brew cleanup

4、删除文件

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*

5、卸载MySQL自动登录

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

6、删除MySQL配置

subl /etc/hostconfig` 
# 删除这一行MYSQLCOM=-YES-

7、删除MySQL Preferences

rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*

8、重新启动机器确保MySQL进程被终止