当前位置:网站首页>MySQL 5.7 resets the root password. I tried the method in N and finally found it
MySQL 5.7 resets the root password. I tried the method in N and finally found it
2022-04-22 06:24:00 【bglmmz】
It's been a while , Several users are also set up , Because I want to modify it recently root password , So use online :
mysqladmin -uroot -pmy_old_pwd password my_new_pwd
To change the password , After restarting the service , Found no modification successful . Tried a few more times , Including direct update mysql.user, Don't successful , Try again later , The following error message appears :
mysqladmin: connect to server at 'localhost' failed.
So I found MySQL 5.7 Official documents of :http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
Follow the steps below :
1. modify my.ini, stay [mysqld] Add a line below :
skip-grant-tables
2. restart mysql
3. stay mysql/bin Under the table of contents , perform mysql -uroot, Connected to the mysql
4. Refer to the official website above ,
5.7.6 Later versions use the following command :
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
After running, the following information will be displayed , It means it didn't succeed
Query OK, 0 rows affected (0.00 sec)
So I'm using 5.7.5 Previous versions of the command :
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
After running, the following information will be displayed , It means it didn't succeed
Query OK, 0 rows affected (0.00 sec)
5. Then use the following command to test :
UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPass') password_expired = 'N'
WHERE User = 'root' AND Host = 'localhost';
Also after operation : Query OK, 0 rows affected
So you don't have to perform the following
FLUSH PRIVILEGES;
6. Then use the following command , loosen where Conditions
update mysql.user set authentication_string=PASSWORD('newpassword') where User='root';
Prompt after execution :Query OK, 1 row affected... It means there's a play
7. take my.ini Change it back , restart mysql, Do a test :root The user's new password is available , The old password is no longer available . Other users are not affected .
版权声明
本文为[bglmmz]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220548531268.html
边栏推荐
猜你喜欢
随机推荐
Oracle efficiently replicates millions of data
2021-11-01
JS逆向实战:有道翻译接口分析
Grafana InfluxDB 简单脚本
redis 集群三 · cluster模式
hash模式与history模式之间的区别
jupyter notebook爬取网页
Partition of MySQL database
thinkphp5怎么隐藏index.php入口文件
Regular verification of two decimal places
元宇宙概念火爆,虚拟地产是否值得投资
PHP month difference
一山更比一山高,熊猫H3与熊猫H3PlUS参数对比
JS调试检测 及 绕过方法
MySQL的InnoDB存储引擎
ldap 验证 页面管理
PHP opens the file and writes the file contents fopen, feof, fgets
supervisord
分布式事务解决方案Seata
Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: “/?k=“









