前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Uninstall all those broken versions of MySQL and re-install it with Brew on Mac Mavericks

Uninstall all those broken versions of MySQL and re-install it with Brew on Mac Mavericks

作者头像
九州暮云
发布2019-08-21 14:20:08
4660
发布2019-08-21 14:20:08
举报
文章被收录于专栏:九州牧云九州牧云

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

代码语言:javascript
复制
mysqldump --all-databases > all_databases_export.sql

Or individually

代码语言:javascript
复制
mysqldump database_name > database_exportname.sql

Stop the database server

>= MySQL 5.7

代码语言:javascript
复制
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

< MySQL 5.7

代码语言:javascript
复制
sudo /usr/local/mysql/support-files/mysql.server stop

Remove MySQL

代码语言:javascript
复制
sudo rm -rf /usr/local/mysq*
代码语言:javascript
复制
sudo rm  /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
代码语言:javascript
复制
sudo rm -rf /Library/StartupItems/MySQLCOM
代码语言:javascript
复制
sudo rm -rf /Library/PreferencePanes/My*

Edit /etc/hostconfig and remove the line MYSQLCOM=

代码语言:javascript
复制
rm -rf ~/Library/PreferencePanes/MySQL*
代码语言:javascript
复制
sudo rm -rf /Library/Receipts/mysql*
代码语言:javascript
复制
sudo rm -rf /Library/Receipts/MySQL*
代码语言:javascript
复制
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:

代码语言:javascript
复制
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/

(2)https://coderwall.com/p/os6woq/uninstall-all-those-broken-versions-of-mysql-and-re-install-it-with-brew-on-mac-mavericks

(3)http://stackoverflow.com/questions/8014500/macosx-autostart-mysql-on-boot

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Back Up any needed databases
  • Stop the database server
    • >= MySQL 5.7
      • < MySQL 5.7
      • Remove MySQL
      • Brew install MySQL
      • Autostart MySQL on boot
      相关产品与服务
      云数据库 SQL Server
      腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档