您好,登錄后才能下訂單哦!
這篇文章主要介紹了mysql 8.0忘記root用戶密碼怎么用,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
忘記了root用戶密碼, 首先使用如下重啟mysqld服務
[root@mysql8-01 ~]# systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
[root@mysql8-01 ~]# systemctl stop mysqld
[root@mysql8-01 ~]# systemctl start mysqld
如果需要使用簡單密碼,需要修改系統參數:
set global validate_password.policy=0;
set global validate_password.length=4;
接下來登錄:
[root@mysql8-01 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.14 MySQL Community Server - GPL
Copyright (c) 2000, 2019, 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.
mysql>
mysql> ALTER USER 'root'@'*' IDENTIFIED BY '123456';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
mysql> ALTER USER 'root'@'*' IDENTIFIED BY '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password.length=4;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> ALTER USER 'root'@'*' IDENTIFIED BY '123456';
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'*'
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> exit
感謝你能夠認真閱讀完這篇文章,希望小編分享的“mysql 8.0忘記root用戶密碼怎么用”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。