溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Linux服務(wù)器---mysql忘記root密碼

發(fā)布時(shí)間:2020-08-10 06:27:19 來(lái)源:ITPUB博客 閱讀:175 作者:一生有你llx 欄目:建站服務(wù)器

忘記root密碼

如果不小心忘記了root密碼,那么mysql就不能再登錄了,這時(shí)就要重置root密碼才行。通過(guò)下面的步驟,我們可以重新設(shè)置root密碼。

1 、退出mysql

[root@localhost src]#  service mysqld stop

停止 mysqld                                              [ 確定 ]

[root@localhost src]# 

 

2 、進(jìn)入sql安全模式,命令“ /usr/bin/mysqld_safe --skip-grant-table &

[root@localhost src]# /usr/bin/mysqld_safe --skip-grant-table &

[1] 6332

[root@localhost src]# 180814 10:10:00 mysqld_safe Logging to '/var/log/mysqld.log'.

180814 10:10:00 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

 

3 、無(wú)密碼方式登錄,命令“mysql –u root”

[root@localhost src]#  mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.1.71 Source distribution

Copyright (c) 2000, 2013, 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> 

 

4 、使用mysql,命令“use mysql;” 

mysql> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> 

 

5 、重設(shè)root密碼,命令“update user set password=password (“密碼”) where user=’root’”

mysql>  update user set password=password('123456') where user='root';

Query OK, 3 rows affected (0.00 sec)

Rows matched: 3  Changed: 3  Warnings: 0

mysql> 

 

6 、刷新 

mysql>  flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

7 、退出,重新登錄

[root@localhost src]#  mysql -u root -p

Enter password:        // 這里輸入新密碼

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Sever version: 5.1.71 Source distribution

Copyright (c) 2000, 2013, 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> 



 做了一個(gè)Linux學(xué)習(xí)的平臺(tái),目前出來(lái)一個(gè)雛形,各位可以參考使用
鏈接:https://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ  密碼:n7bk

Linux服務(wù)器---mysql忘記root密碼





向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI