Mac使用brew安装与配置MySQL

使用Homebrew安装MySQL

  1. 如果没有安装Homebrew,首先安装Homebrew
    • 打开终端输入以下命令:
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
  1. 使用Homebrew安装命令
brew install mysql
  1. 启动mysql服务
mysql.server start
  1. 初始化mysql配置
HaojiedeiMac:~ haojie$ mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: n  // 这个选yes的话密码长度就必须要设置为8位以上,但我只设置4位
Please set the password for root here.

New password:               // 设置密码

Re-enter new password:      // 再一次确认密码
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y       // 移除不用密码的那个账户
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n     //不接受root远程登录账号

... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y    //删除test数据库
- Dropping test database...
Success.

- Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y      // 是否重新加载授权信息
Success.

All done! 

文章作者: Hao Jie
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Hao Jie !
  目录