简体   繁体   English

MySQL root用户密码设置为空字符串

[英]Mysql root user password set to empty string

I've repeatedly tried to set a password for the root mysql user, originally there was no password at all. 我反复尝试为root mysql用户设置密码,最初根本没有密码。 However, after resetting it, via code I found from tutorials on the subject: 但是,重置之后,通过代码从主题教程中找到了:

mysqld_safe --skip-grant-tables &
UPDATE user SET authentication_string=PASSWORD("mypasswordhere") where User='root';
FLUSH PRIVILEGES;

The terminal says I set the password correctly, but when I try to log back in with the password, it doesn't work. 终端说我正确设置了密码,但是当我尝试使用密码重新登录时,它不起作用。 What I found is that it's setting the password to an empty string, does anyone know why? 我发现这是将密码设置为空字符串,有人知道为什么吗?

I had some problems to set the password using PASSWORD() function because the validate_password plugin was activated, to bypass this plugin, I created the authentication_string value before setting the new password. 我使用PASSWORD()函数设置密码时遇到一些问题,因为激活了validate_password插件,为了绕过该插件,我在设置新密码之前创建了authentication_string值。

You don't need run mysql in safe mode mysql_safe --skip-grant-tables to change a password, just start normally and try this: 您不需要在安全模式下运行mysql_safe --skip-grant-tables来更改密码,只需正常启动并尝试以下操作:

# mysql -uroot

mysql> SELECT PASSWORD('HELLO');
+-------------------------------------------+
| PASSWORD('HELLO')                         |
+-------------------------------------------+
| *C1BCFD6877BB358C0518ECCD6D5A70BFF7D0A174 |
+-------------------------------------------+
1 row in set, 1 warning (0.00 sec)

mysql> use mysql;

mysql> update user set authentication_string="*C1BCFD6877BB358C0518ECCD6D5A70BFF7D0A174" where User='root';
mysql> flush privileges;
mysql> quit

# mysql -uroot -pHELLO

mysql> 

Another simple solution is the ALTER USER command: 另一个简单的解决方案是ALTER USER命令:

ALTER USER 'root'@'localhost' IDENTIFIED BY '*C1BCFD6877BB358C0518ECCD6D5A70BFF7D0A174';

If these solutions not work, please show the output from the commands and which MySQL version you using to test. 如果这些解决方案不起作用,请显示命令的输出以及您要测试的MySQL版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 mysql:无法为MySQL“ root”用户设置密码 - mysql : Unable to set password for the MySQL “root” user 无法为 MySQL root 用户设置密码 - Cannot set password for MySQL root user 如何为MySQL设置root用户密码 - How to set root user password for MySQL mysql中的用户root如何设置密码admin? - How to set the password admin to the user root in mysql? MySQL Server 5.5:无法为MySQL“ root”用户设置密码 - MySQL Server 5.5 : unable to set password for the MySQL “root” user mysql安装错误:无法为MySQL“ root”用户设置密码 - Mysql installation error:Unable to set password for the MySQL “root” user Ansible安装MySql 5.7 - 设置Root用户密码 - Ansible Install MySql 5.7 - Set Root User Password 安装erpnext时如何为mysql设置root用户密码? - How to set root user password for mysql while installing erpnext? 无法为MySQL“ root”用户设置密码:为MySQL管理用户设置密码时发生错误 - Unable to set password for the MySQL “root” user: An error occurred while setting the password for the MySQL administrative user MYSQL_ROOT_PASSWORD 已设置但在 docker 容器中出现“用户 'root'@'localhost'(使用密码:YES)拒绝访问” - MYSQL_ROOT_PASSWORD is set but getting "Access denied for user 'root'@'localhost' (using password: YES)" in docker container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM