Mysql On Mac OS: Remove & Install

本文档详细介绍了如何在MacOS系统中彻底卸载MySQL,并通过Homebrew重新安装MySQL的方法。包括了备份数据库、停止服务、删除配置文件等卸载步骤,以及使用Homebrew安装和启动MySQL服务的具体操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

If you downloaded and installed from .dmg package already, and mightbe sometime it sucks because of some reason like me, i gem install mysql2.

1 Remove mysql from you Mac OS X

1.1 backup your database by mysqldump, of course if you want to.

1.2 stop the database. "sudo mysqladmin shutdown" or from the preference panel.

1.3 remove MySQL binary and configuration files

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*

 1.4 If MySQL automatically at boot and the system preference panel,

sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
rm -rf ~/Library/PreferencePanes/My*

 1.5 mac OS keeps track of installed applications by tracking "receipts". 

sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*

 Then look for receipts in a different location. Open up /Library/Receipts/InstallHistory.plist, find the entry for MySQL, delete the entry.

One more location: look in /private/var/db/receipts/ and search for mysql in the directory. There should be 2 files, delete them.

 

2 Install by Homebrew

brew install mysql

mkdir -p ~/Library/LaunchAgents
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
mysql.server start
 

 

Then if mysql start successfully, 

mysql_secure_installation

 step by step.

 

PS: You might get this error:

 “ERROR! The server quit without updating PID file”.

sudo chmod -R 755 /usr/local/var/mysql
$ rm -Rf /usr/local/var/mysql/Your-Machine-Name.local.err

 2 

ps aux | grep mysql

 Then "kill -9 xxxx" to kill all the progress.

3

mv /etc/my.cnf /etc/my.cnf.old

 

4

mv /var/lib/mysql/ib_logfile* /root/

 May be other reasons, hope this helps.

 

http://nali.org/remove-mysql-from-mac-os-x-snow-leopord/

http://benjsicam.me/blog/how-to-install-mysql-on-mac-os-x-using-homebrew-tutorial/

http://linuxadministrator.pro/blog/?p=225

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值