Mac下Brew安装Mysql8.0.29空密码无法登录,mysql_secure_installation也无法使用

admin 2022-07-22 22:19:19 186

安装Mysql8.0.29默认空密码登录不了,安全模式启动(mysqld --skip-grant-tables) 能登录,但是没法设置密码。。。

其实brew安装mysql后,首次启动日志里有个密码,如下

2022-07-22T14:00:25.080112Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ujNHaIFXu0:i

这个密码(ujNHaIFXu0:i)就是运行Mysql安全安装指令的密码,如下:

➜  ~ mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:(这里要输入那个密码,不如会如下报错)
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61)
# 下面是正确输入密码后的配置过程。。。
➜  ~ mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:

The existing password for the user account root has expired. Please set a new password.

New password:

Re-enter new 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: y

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: 0
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

 ... skipping.
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) : n

 ... 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) : y
Success.

All done!

另外Mysql8要求密码最低8位还得字符大小写啊什么的组合,我就要设置个 123456的密码怎么办呢?如下:

#先用你的root用户登录,然后执行就行,主要是后面三个,理论上你安装初始化的时候策略已经是LOW了。。。
#降低安全策略等级
set global validate_password.policy=LOW;
#降低密码长度需求
set global validate_password.length=4;
#设置英文字母(包含大小写)最小长度
set global validate_password.mixed_case_count=0;
#设置特殊字符最小长度
set global validate_password.special_char_count=0;
可爱猫🐅Telegram电报群 https://t.me/ikeaimao

社区声明 1、本站提供的一切软件、教程和内容信息仅限用于学习和研究目的
2、本站资源为用户分享,如有侵权请邮件与我们联系处理敬请谅解!
3、本站信息来自网络,版权争议与本站无关。您必须在下载后的24小时之内,从您的电脑或手机中彻底删除上述内容
最新回复 (0)

您可以在 登录 or 注册 后,对此帖发表评论!

返回