mac 安装 mysql
安装MySQL
brew install mysql
MySQL开机启动:
1 | ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents |
安装完成之后开启MySQL安全机制:/usr/local/opt/mysql/bin/mysql_secure_installation
> secure enough. Would you like to setup VALIDATE PASSWORD plugin?
输入y
1 | There are three levels of password validation policy: |
根据情况选择密码的要求,可以输入0 or 1 or 2
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No):
输入nDo you wish to continue with the password provided?(Press y|Y for Yes, any other key for No):
输入yRemove anonymous users? (Press y|Y for Yes, any other key for No):
输入yDisallow root login remotely? (Press y|Y for Yes, any other key for No):
输入yRemove test database and access to it? (Press y|Y for Yes, any other key for No):
输入yReload privilege tables now? (Press y|Y for Yes, any other key for No):
输入y
连接数据库
mysql -uroot -p
输入root用户的密码,然后你可以看到MySQL console:
1 | Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. |
退出MySQL console
1 | mysql> \q |
设置mysql快捷服务控制命令
为了后面管理方便,将命令 alias 下,vim ~/.bash_aliases
输入一下内容:
1 | alias mysql.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist" |
参考资料:Install Nginx, PHP-FPM, MySQL and phpMyAdmin on OS X Mavericks using Homebrew