通过brew来安装homebrew
brew install mysql
等待下载完成;
mysql.server start
执行启动mysql服务
如果启动失败可以使用
brew services start mysql
命令开启mysql服务
brew services stop mysql
命令关闭mysql服务
mysql_secure_installation
命令进行配置mysql密码等设置
注意密码等级尽量选择low,如果不连公网使用的话。如果密码等级输入错误想要修改
出现以下错误
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements。
解决办法
执行以下命令
mysqld --skip-grant-tables
新建命令行
命令行输入
mysql
直接进入mysql界面
mysql> set global validate_password.policy=0; //修改密码等级为low
mysql> set global validate_password.length=1; //设置密码长度
#注意这个命令适用于mysql 8以上版本
基本上默认yes,除了允许远程访问no;
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Please set the password for root here.
//输入密码
New password:
//再次输入密码
Re-enter new password:
Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
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
... 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
- 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!
最后启动就行。