Homebrew安装和卸载MySql

安装MySql

$ brew install mysql

设置MySql开机启动

$ mkdir -p ~/Library/LaunchAgents    # 首先确认该目录是否存在,若已经存在不用执行本命令  
$ ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents  
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

启动MySql服务

$ mysql.server start  

错误修复
如果在启动过程中出现如下错误:ERROR! The server quit without updating PID file,使用以下方法修复。

$ sudo chmod -R 755 /usr/local/var/mysql
$ rm -Rf /usr/local/var/mysql/用户名.local.err

MySql安全性设置

$ mysql_secure_installation

Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y  

使用Homebrew卸载MySql

$ brew remove mysql
$ brew cleanup
$ launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
$ rm -Rf ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist  

你可能感兴趣的:(Homebrew安装和卸载MySql)