赞
踩
通过brew安装完mysql后执行以下命令
mysql.server start
mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD PLUGIN 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 plugin?
Press y|Y for Yes, any other key for No: y
//是否使用VALIDATE PASSWORD PLUGIN,这个看自己了
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:
//1(这里我选了1,即MEDIUM,密码需要有大小写字母、数字、特殊符号)
Please set the password for root here.
New password: (输入你的密码)
Re-enter new password: (再次输入你的密码)
Estimated strength of the password: 100
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) : (是否禁止root远程登录,根据自己的需求选择Y/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) : (是否删除test数据库,直接回车)
... skipping.
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) : (是否重新加载权限表,直接回车)
... skipping.
All done!
在mac os环境下,安装了mysql之后出现连接不成功(第三方软件),通常是因为新版的mysql中新增了不同的密码加密机制,我们需要将加密机制改为旧版本的。
到系统偏好设置中找到mysql,到mysql服务中点击Initialize Database
,勾选Use legacy password
,重新启动服务,连接成功。
如果是通过brew安装的mysql,在系统偏好设置中找不到mysql图标,需要通过命令行来修改,linux系统中也遇到过同类型的问题
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NewPassword@123456';
FLUSH PRIVILEGES;
这里设置密码很蛋疼,是因为mysql默认密码强度为中等强度。需要大小写、特殊字符、数字,可以先通过两个全局设置改变,而因为新旧版本的mysql密码教养规则不同,我们可以通过SHOW VARIABLES LIKE 'validate_password%';
来查看对应的规则是什么然后通过以下代码修改强度跟长度即可
set global validate_password.policy = 0
set global validate_password.length = 4
但是!我发现一开始初始化的时候,如果选择了使用VALIDATE PASSWORD PLUGIN插件并进行设置之后,再做修改似乎是没有效果的
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。