网址
HomeBrew 搜索 MySQL https://formulae.brew.sh/formula/mysql#default
安装 MySQL
brew install mysql
MySQL 初始化账户
注: 本地数据库一般仅用来开发测试,所以忽略一些安全措施
mysql_secure_installation
输入 n , 回车, 不使用强度高的密码
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
输入root密码,回车, 需要输入两次, 比如: 123456
Please set the password for root here.
New password:
Re-enter new password:
输入 y , 回车,删除游客用户
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
输入 n, 回车,允许 root 远程登录
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
输入 y, 回车,删除测试的数据库
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
输入 y,回车, 重新加载权限
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
服务管理
重启 MySQL 服务
brew services restart mysql
启动 MySQL 服务
brew services start mysql
停止 MySQL 服务
brew services stop mysql