共計 1658 個字符,預計需要花費 5 分鐘才能閱讀完成。
這篇文章主要為大家展示了“MySQL 如何忘記 root 密碼”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓丸趣 TV 小編帶領大家一起研究并學習一下“MySQL 如何忘記 root 密碼”這篇文章吧。
1、啟動 MySQL
[root@localhost ~]# mysqld_safe –skip-grant-tables
2、登錄 MySQL
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.25a-log Source distribution
Copyright (c) 2000, 2011, 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 show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| allen |
| mysql |
| mytest |
| performance_schema |
| test |
+——————–+
6 rows in set (0.00 sec)
mysql use mysql
Database changed
mysql update user set password=PASSWORD(123456) where user= root – 修改 root 密碼
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql quit
Bye
3、重新使用密碼登錄
[root@localhost ~]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.25a-log Source distribution
Copyright (c) 2000, 2011, 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 show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| allen |
| mysql |
| mytest |
| performance_schema |
| test |
+——————–+
6 rows in set (0.00 sec)
以上是“MySQL 如何忘記 root 密碼”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注丸趣 TV 行業資訊頻道!