溫馨提示×

溫馨提示×

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

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

MySQL如何進(jìn)行密碼管理

發(fā)布時(shí)間:2021-11-02 11:33:21 來源:億速云 閱讀:142 作者:小新 欄目:MySQL數(shù)據(jù)庫

這篇文章主要介紹了MySQL如何進(jìn)行密碼管理,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

1. mysql安裝后默認(rèn)沒有密碼,初始化安裝后默認(rèn)密碼登錄,需要馬上修改root密碼。
[root@mysql ~]# cat /root/.mysql_secret    --查看root賬號密碼
# The random password set for the root user at Tue Dec 13 18:59:06 2016 (local time): 7MhtyX3aZEl9OUf8
[root@mysql ~]# mysql -uroot -p    -- 登錄mysql
Enter password:               --(此處復(fù)制粘貼 7MhtyX3aZEl9OUf8)
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.25
Copyright (c) 2000, 2015, 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.
說明:  出現(xiàn)mysql>   表示一切順利成功。




2.  修改密碼
mysql> SET PASSWORD = PASSWORD('123456');   --設(shè)置密碼為123456
[root@mysql etc]# mysql -uroot -p123456     --修改密碼后,登錄
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 39
Server version: 5.6.25 MySQL Community Server (GPL)
mysql>     --登錄成功




3. 忘記mysql數(shù)據(jù)庫root的密碼后,如何修改密碼。
[root@mysql etc]# service mysql stop   --停止mysql進(jìn)程
Shutting down MySQL.... SUCCESS! 
[root@mysql etc]# mysqld_safe --skip-grant-tables&  --啟動(dòng)mysql時(shí)不啟動(dòng)grant-tables,授權(quán)表。執(zhí)行后出現(xiàn)下面畫面,另起一個(gè)新會話。
[1] 3574
[root@mysql etc]# 161215 06:13:53 mysqld_safe Logging to '/var/lib/mysql/mysql.err'.
161215 06:13:53 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[root@mysql ~]# ps -ef|grep mysql   --查看mysql進(jìn)程是否起來
root       3467   3440  0 05:29 pts/2    00:00:00 mysql -uandy -px xx
root       3574   2845  0 06:13 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-tables
mysql      3677   3574  2 06:13 pts/0    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-
mysql> UPDATE user SET password=PASSWORD('cccccc') WHERE user='root';   --更改root密碼
Query OK, 4 rows affected (0.04 sec)
Rows matched: 4  Changed: 4  Warnings: 0
mysql> FLUSH PRIVILEGES;    --權(quán)限更新
Query OK, 0 rows affected (0.00 sec)
[root@mysql ~]# mysql -uroot -p123456    --使用舊密碼登錄,發(fā)現(xiàn)不行,說明密碼已經(jīng)更新
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@mysql ~]# mysql -uroot -pcccccc   --新密碼登錄成功
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
mysql>

感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“MySQL如何進(jìn)行密碼管理”這篇文章對大家有幫助,同時(shí)也希望大家多多支持億速云,關(guān)注億速云行業(yè)資訊頻道,更多相關(guān)知識等著你來學(xué)習(xí)!

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

免責(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)容。

AI