[英]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.