溫馨提示×

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

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

mysql8.0忘記登錄密碼怎么辦

發(fā)布時(shí)間:2020-05-30 13:59:02 來(lái)源:億速云 閱讀:336 作者:Leah 欄目:系統(tǒng)運(yùn)維

mysql8.0忘記登錄密碼怎么辦?針對(duì)這個(gè)問(wèn)題,今天小編總結(jié)這篇有關(guān)找回密碼的文章,希望幫助更多想解決這個(gè)問(wèn)題的同學(xué)找到更加簡(jiǎn)單易行的辦法。

pkill mysqld 關(guān)閉掉mysql

跳過(guò)MySQL的權(quán)限表啟動(dòng)MySQL服務(wù):
--skip-grant-tables啟動(dòng)mysql

/usr/local/mysql8013/bin/mysqld_safe --defaults-file=/data/mysql8/my8.cnf --skip-grant-tables & 

將密碼置空:

root@localhost [(none)]>update mysql.user set authentication_string='' where user="root" and host="localhost";
Query OK, 1 row affected (0.06 sec)
Rows matched: 1  Changed: 1  Warnings: 0

root@localhost [(none)]>

pkill mysqld 關(guān)閉掉mysql

再次啟動(dòng)mysql服務(wù)

[root@localhost ~]# /usr/local/mysql8013/bin/mysqld --defaults-file=/data/mysql8/my8.cnf &

無(wú)密碼登錄MySQL服務(wù)并設(shè)置新的密碼:

root@localhost [(none)]>select version();
+-----------+
| version() |
+-----------+
| 8.0.13    |
+-----------+
root@localhost [(none)]>alter user user() identified by 'jist558@wei';

[root@localhost ~]# mysql -uroot -p'jist558@wei' -e "select version();"
mysql: [Warning] Using a password on the command line interface can be insecure.
+-----------+
| version() |
+-----------+
| 8.0.13    |
+-----------+

密碼寫入.my.cnf文件就可以mysql直接登錄mysql窗口:

[root@localhost ~]# cat .my.cnf 
[mysql]
prompt="\u@\h:\p \R:\m:\s[\d]>"
no-auto-rehash
user=root
password=jist558@wei
[root@localhost ~]# mysql -e "select version();"
+-----------+
| version() |
+-----------+
| 8.0.13    |
+-----------+

關(guān)于mysql8.0忘記登錄密碼解決辦法就分享到這里了,解決問(wèn)題并不止文章中和大家分析的辦法,不過(guò)本文分析的方法準(zhǔn)確性是不容置疑的。更多相關(guān)內(nèi)容歡迎關(guān)注億速云行業(yè)資訊頻道。

向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