大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
忘记MySQL root管理员帐号密码的处理方法是怎样的,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
创新互联建站是网站建设技术企业,为成都企业提供专业的做网站、网站建设,网站设计,网站制作,网站改版等技术服务。拥有十余年丰富建站经验和众多成功案例,为您定制适合企业的网站。十余年品质,值得信赖!
丢失root密码,意味着不能以超级管理员帐号登录数据库,进行维护工作。需要找回root密码。
丢失root密码,意味着不能以超级管理员帐号登录数据库,进行维护工作。需要找回root密码。
杀掉mysql进程,然后添加一个参数–skip-grant-tables跳过权限表,启动mysql实例,然后以无密码方式登录数据库,修改root用户密码,再关闭mysql实例(关闭或者kill mysql进程),最后正常启动mysql实例,就可以使用root用户登录数据库了。
点击阅读原文,提升阅读体验: https://www.modb.pro/db/22826?cyn
mysql -uroot -p
ps -ef|grep mysql
kill -9 mysql进程号
mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables &
mysql
use mysql;
update user set authentication_string=password(‘oracle123’) where user=‘root’;
flush privileges;
mysqladmin -p shutdown
mysqld_safe --defaults-file=/etc/my.cnf &
mysql -uroot -p
[root@source ~]# mysql -uroot -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) ==故意输错密码,模拟root密码丢失== [root@source ~]# [root@source ~]# ps -ef|grep mysql root 6733 6191 0 10:28 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf mysql 7029 6733 2 11:10 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=source.err --pid-file=source.pid --port=3306 root 7063 6191 0 11:10 pts/0 00:00:00 grep mysql [root@source ~]# [root@source ~]# kill -9 7029 6733 [root@source ~]# [1]+ Killed mysqld_safe --defaults-file=/etc/my.cnf [root@source ~]# [root@source ~]# ps -ef|grep mysql root 7066 6191 0 11:10 pts/0 00:00:00 grep mysql [root@source ~]# [root@source ~]# [root@source ~]# mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables & [1] 7286 [root@source ~]# 2020-02-16T03:11:41.998645Z mysqld_safe Logging to '/data/mysql/source.err'. 2020-02-16T03:11:42.020962Z mysqld_safe Starting mysqld daemon with databases from /data/mysql [root@source ~]# [root@source ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.20-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. root@db 11:11: [(none)]> root@db 11:11: [(none)]> root@db 11:12: [(none)]> root@db 11:12: [(none)]> use mysql; Database changed root@db 11:12: [mysql]> root@db 11:12: [mysql]> update user set authentication_string=password('oracle123') where user='root'; ==修改密码== Query OK, 1 row affected, 1 warning (0.01 sec) Rows matched: 2 Changed: 1 Warnings: 1 root@db 11:13: [mysql]> root@db 11:13: [mysql]> flush privileges; Query OK, 0 rows affected (0.00 sec) root@db 11:13: [mysql]> root@db 11:14: [mysql]> exit Bye [root@source ~]# [root@source ~]# mysqladmin -p shutdown Enter password: [root@source ~]# [root@source ~]# 2020-02-16T03:15:27.217666Z mysqld_safe mysqld from pid file /data/mysql/source.pid ended [1]+ Done mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables [root@source ~]# [root@source ~]# ps -ef|grep mysql root 7502 6191 0 11:15 pts/0 00:00:00 grep mysql [root@source ~]# [root@source ~]# mysqld_safe --defaults-file=/etc/my.cnf & [1] 7503 [root@source ~]# 2020-02-16T03:15:57.181920Z mysqld_safe Logging to '/data/mysql/source.err'. 2020-02-16T03:15:57.217614Z mysqld_safe Starting mysqld daemon with databases from /data/mysql [root@source ~]# [root@source ~]# mysql -uroot -p Enter password: ==root密码找回后,正常登录== Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.20-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. root@db 11:16: [(none)]>
看完上述内容,你们掌握忘记mysql root管理员帐号密码的处理方法是怎样的的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注创新互联行业资讯频道,感谢各位的阅读!