更改密码后无法登录 mysql 5.7.9
Can not login to mysql 5.7.9 after change password
我已经安装了 Mysql Ver 14.14 Distrib 5.7.9,用于 Linux (x86_64) 使用 EditLine wrapper 在 CentOS Linux 版本 7.1.1503
我使用此命令更改了 root 密码:
alter user 'root'@'localhost' identified by 'XXXXXXX';
flush privileges;
重新登录后
[root@server ~]# mysql -u root -p
Enter password:
ERROR 1524 (HY000): Plugin
'*A6074285732753D325C55AD74E7517CF442C1A81' is not loaded
您应该在 mysql 用户 table 上更新任何用户,尤其是 root。
您应该按照以下步骤重置它:
How to reset the root password for mysql:
Stop mysql:
1. service mysql stop
Run mysql with skip grants to be able to login without any password
2. mysqld_safe --skip-grant-tables &
Login as root
3. mysql -u root
4. mysql commands:
mysql> use mysql;
mysql> update user set password=PASSWORD("YourPWHere") where User='root';
mysql> flush privileges;
mysql> quit
Stop mysql
5. service mysql stop
Start mysql normally:
6. service mysql start
Try to login using your new password:
7. mysql -u root -p
更新:
自早期版本 mySQL(我使用的是 5.7.10)以来,有两件事发生了变化:
systemd
现在用于照顾 mySQL 而不是 mysqld_safe
(这就是为什么我收到 -bash: mysqld_safe: command not found
错误 - 它不是安装)
user
table 结构已更改。
所以要重置 root 密码,您仍然使用 --skip-grant-tables
选项开始 mySQL 并更新 user
table,但是您的操作方式已经改变。
1. Stop mysql:
systemctl stop mysqld
2. Set the mySQL environment option
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
3. Start mysql usig the options you just set
systemctl start mysqld
4. Login as root
mysql -u root
5. Update the root user password with these mysql commands
mysql> UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword')
-> WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit
6. Stop mysql
systemctl stop mysqld
7. Unset the mySQL envitroment option so it starts normally next time
systemctl unset-environment MYSQLD_OPTS
8. Start mysql normally:
systemctl start mysqld
Try to login using your new password:
7. mysql -u root -p
参考
如 http://dev.mysql.com/doc/refman/5.7/en/mysqld-safe.html、
所述
Note
As of MySQL 5.7.6, for MySQL installation using an RPM
distribution, server startup and shutdown is managed by systemd on
several Linux platforms. On these platforms, mysqld_safe is no longer
installed because it is unnecessary. For more information, see Section
2.5.10, “Managing MySQL Server with systemd”.
它会将您带到 http://dev.mysql.com/doc/refman/5.7/en/server-management-using-systemd.html,它在页面底部提到了 systemctl set-environment MYSQLD_OPTS=
。
密码重置命令位于 http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
的底部
使用以下步骤重置密码。
$ sudo systemctl start mysqld
重置 MySql 服务器 root 密码。
$sudo grep 'temporary password' /var/log/mysqld.log
输出类似-:
10.744785Z 1 [Note] A temporary password is generated for root@localhost: o!5y,oJGALQa
在重置 mysql_secure_installation 过程中使用上述密码。
$ sudo mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
您已成功重置 MySql 服务器的 root 密码。
使用以下命令检查 mysql 服务器是否连接。
$ mysql -u root -p
我已经安装了 Mysql Ver 14.14 Distrib 5.7.9,用于 Linux (x86_64) 使用 EditLine wrapper 在 CentOS Linux 版本 7.1.1503
我使用此命令更改了 root 密码:
alter user 'root'@'localhost' identified by 'XXXXXXX';
flush privileges;
重新登录后
[root@server ~]# mysql -u root -p
Enter password:
ERROR 1524 (HY000): Plugin '*A6074285732753D325C55AD74E7517CF442C1A81' is not loaded
您应该在 mysql 用户 table 上更新任何用户,尤其是 root。
您应该按照以下步骤重置它:
How to reset the root password for mysql:
Stop mysql:
1. service mysql stop
Run mysql with skip grants to be able to login without any password
2. mysqld_safe --skip-grant-tables &
Login as root
3. mysql -u root
4. mysql commands:
mysql> use mysql;
mysql> update user set password=PASSWORD("YourPWHere") where User='root';
mysql> flush privileges;
mysql> quit
Stop mysql
5. service mysql stop
Start mysql normally:
6. service mysql start
Try to login using your new password:
7. mysql -u root -p
更新:
自早期版本 mySQL(我使用的是 5.7.10)以来,有两件事发生了变化:
systemd
现在用于照顾 mySQL 而不是mysqld_safe
(这就是为什么我收到-bash: mysqld_safe: command not found
错误 - 它不是安装)user
table 结构已更改。
所以要重置 root 密码,您仍然使用 --skip-grant-tables
选项开始 mySQL 并更新 user
table,但是您的操作方式已经改变。
1. Stop mysql:
systemctl stop mysqld
2. Set the mySQL environment option
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
3. Start mysql usig the options you just set
systemctl start mysqld
4. Login as root
mysql -u root
5. Update the root user password with these mysql commands
mysql> UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword')
-> WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit
6. Stop mysql
systemctl stop mysqld
7. Unset the mySQL envitroment option so it starts normally next time
systemctl unset-environment MYSQLD_OPTS
8. Start mysql normally:
systemctl start mysqld
Try to login using your new password:
7. mysql -u root -p
参考
如 http://dev.mysql.com/doc/refman/5.7/en/mysqld-safe.html、
所述Note
As of MySQL 5.7.6, for MySQL installation using an RPM distribution, server startup and shutdown is managed by systemd on several Linux platforms. On these platforms, mysqld_safe is no longer installed because it is unnecessary. For more information, see Section 2.5.10, “Managing MySQL Server with systemd”.
它会将您带到 http://dev.mysql.com/doc/refman/5.7/en/server-management-using-systemd.html,它在页面底部提到了 systemctl set-environment MYSQLD_OPTS=
。
密码重置命令位于 http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
的底部使用以下步骤重置密码。
$ sudo systemctl start mysqld
重置 MySql 服务器 root 密码。
$sudo grep 'temporary password' /var/log/mysqld.log
输出类似-:
10.744785Z 1 [Note] A temporary password is generated for root@localhost: o!5y,oJGALQa
在重置 mysql_secure_installation 过程中使用上述密码。
$ sudo mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
您已成功重置 MySql 服务器的 root 密码。 使用以下命令检查 mysql 服务器是否连接。
$ mysql -u root -p