To remove an instance of MySQL from your macOS or OSX installation you need to delete a number of files via the command line, but first ensure that you have database dumps of your databases and that then the database server is not running.
Back Up any needed databases
All of them
mysqldump --all-databases > all_databases_export.sql
Or individually
mysqldump database_name > database_exportname.sql
Stop the database server
>= MySQL 5.7
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
< MySQL 5.7
sudo /usr/local/mysql/support-files/mysql.server stop
Remove MySQL
sudo rm -rf /usr/local/mysq*
sudo rm /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
Edit /etc/hostconfig and remove the line MYSQLCOM=
rm -rf ~/Library/PreferencePanes/MySQL*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*
That’s it MySQL is now totally removed from your system
Brew install MySQL
- brew doctor and fix any errors
- brew update
- brew install mysql
- unset TMPDIR
- mysql_install_db --verbose --user=
whoami--basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp - mysql.server start
- run the commands Brew suggests, add MySQL to launchctl so it automatically launches at startup
Autostart MySQL on boot
brew info mysql gives you the instructions for loading MySQL at startup, but here's all you need to do:
mkdir -p ~/Library/LaunchAgents
cp `brew --prefix mysql`/*mysql*.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/*mysql*.plist
mysql should now work and be running all the time as expected
reference:
(1)https://coolestguidesontheplanet.com/remove-mysql-from-macos-or-osx-via-the-command-line/;
(3)http://stackoverflow.com/questions/8014500/macosx-autostart-mysql-on-boot。
本文提供了一套详细的指南,介绍如何在MacOS系统中彻底卸载MySQL,包括备份数据库、停止数据库服务及删除所有相关文件。同时,还介绍了如何使用Homebrew重新安装MySQL,并设置MySQL随系统启动。

2132

被折叠的 条评论
为什么被折叠?



