您好,登錄后才能下訂單哦!
忘記mysql root管理員帳號密碼的處理方法是怎樣的,相信很多沒有經(jīng)驗(yàn)的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個(gè)問題。
丟失root密碼,意味著不能以超級管理員帳號登錄數(shù)據(jù)庫,進(jìn)行維護(hù)工作。需要找回root密碼。
丟失root密碼,意味著不能以超級管理員帳號登錄數(shù)據(jù)庫,進(jìn)行維護(hù)工作。需要找回root密碼。
殺掉mysql進(jìn)程,然后添加一個(gè)參數(shù)–skip-grant-tables跳過權(quán)限表,啟動(dòng)mysql實(shí)例,然后以無密碼方式登錄數(shù)據(jù)庫,修改root用戶密碼,再關(guān)閉mysql實(shí)例(關(guān)閉或者kill mysql進(jìn)程),最后正常啟動(dòng)mysql實(shí)例,就可以使用root用戶登錄數(shù)據(jù)庫了。
點(diǎn)擊閱讀原文,提升閱讀體驗(yàn): https://www.modb.pro/db/22826?cyn
mysql -uroot -p
ps -ef|grep mysql
kill -9 mysql進(jìn)程號
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) ==故意輸錯(cuò)密碼,模擬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)]>
看完上述內(nèi)容,你們掌握忘記mysql root管理員帳號密碼的處理方法是怎樣的的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。