Mac OS安裝卸載MySQL教程

來源:互聯網
上載者:User

本安裝/卸載方法適用於Mac OS各個版本,mavericks,lion等等等。


安裝:

只需兩步:第一行指令安裝工具homebrew,第二行通過homebrew安裝mysql。homebrew是一種極其強大的工具,未來還可能會用到很多,具體介紹參見官網:http://brew.sh/

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

brew install mysql

安裝過後還需對MySQL進行配置。

依次執行以下三條命令。注意第一條和第三條中得5.5.20是你安裝的mysql版本,需要針對具體情況改。可以通過ls /usr/local/Cellar/mysql/ 查看你所安裝的哪個版本。第二天中的whoami也是需要改成使用者名稱,可通過指令 whoami獲得。

#setup daemonmkdir -p ~/Library/LaunchAgents && cp /usr/local/Cellar/mysql/5.5.20/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/ && launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist#Set up databases to run as your user accountunset TMPDIR && mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp#start mysqlmysql.server start#secure mysql/usr/local/Cellar/mysql/5.5.20/bin/mysql_secure_installation


卸載:

搜了很多卸載的方法,很多暴力刪除檔案的方法總是讓人心存芥蒂,經過多方調研找到如下最乾淨安全的卸載指令:

sudo rm -rf /Library/StartupItems/MySQLCOM

sudo rm -rf /Library/PreferencePanes/My*

rm -rf ~/Library/PreferencePanes/My*

sudo rm -rf /Library/Receipts/mysql*

sudo rm -rf /Library/Receipts/MySQL*

sudo rm -rf /var/db/receipts/com.m

sudo vim /etc/hostconfig


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.