This installation/uninstall method is applicable to various Mac OS versions, such as mavericks and lion.
Installation:
Only two steps are required: the first line command installs the tool homebrew, and the second line uses homebrew to install mysql. Homebrew is an extremely powerful tool that may be used in the future. For more information, see the official website: http://brew.sh/
Ruby-e "$ (curl-fsSL https://raw.github.com/Homebrew/homebrew/go/install )"
Brew install mysql
After installation, you must configure MySQL.
Run the following three commands in sequence. Note that 5.5.20 is the mysql version you have installed in articles 1 and 3. You need to modify the version according to the actual situation. You can use ls/usr/local/Cellar/mysql/to check which version you have installed. The whoami in the next day also needs to be changed to the user name, which can be obtained through instructions 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
Uninstall:
I searched a lot of uninstallation methods, and many violent methods of deleting files are always difficult. After investigation by multiple parties, I found the following clean and safe uninstallation commands:
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