mysql學習之-密碼管理(預設密碼,修改密碼,解決忘記密碼)
1. mysql安裝後預設沒有密碼,初始化安裝後預設密碼登入,需要馬上修改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: --(此處複製貼上 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.
說明: 出現mysql> 表示一切順利成功。
2. 修改密碼
mysql> SET PASSWORD = PASSWORD('123456'); --設定密碼為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資料庫root的密碼後,如何修改密碼。
[root@mysql etc]# service mysql stop --停止mysql程式
Shutting down MySQL.... SUCCESS!
[root@mysql etc]# mysqld_safe --skip-grant-tables& --啟動mysql時不啟動grant-tables,授權表。執行後出現下面畫面,另起一個新會話。
[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程式是否起來
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; --許可權更新
Query OK, 0 rows affected (0.00 sec)
[root@mysql ~]# mysql -uroot -p123456 --使用舊密碼登入,發現不行,說明密碼已經更新
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>
[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: --(此處複製貼上 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.
說明: 出現mysql> 表示一切順利成功。
2. 修改密碼
mysql> SET PASSWORD = PASSWORD('123456'); --設定密碼為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資料庫root的密碼後,如何修改密碼。
[root@mysql etc]# service mysql stop --停止mysql程式
Shutting down MySQL.... SUCCESS!
[root@mysql etc]# mysqld_safe --skip-grant-tables& --啟動mysql時不啟動grant-tables,授權表。執行後出現下面畫面,另起一個新會話。
[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程式是否起來
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; --許可權更新
Query OK, 0 rows affected (0.00 sec)
[root@mysql ~]# mysql -uroot -p123456 --使用舊密碼登入,發現不行,說明密碼已經更新
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>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31383567/viewspace-2130606/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL8.0 忘記 root 密碼下如何修改密碼MySql密碼
- mysql忘記密碼解決方案MySql密碼
- mysql 忘記密碼MySql密碼
- MySQL忘記密碼MySql密碼
- Mysql忘記密碼解決方法凹MySql密碼
- Jenkins忘記密碼解決方案Jenkins密碼
- centos7 修改root密碼 密碼忘記的情況下CentOS密碼
- PbootCMS忘記密碼後的重置密碼流程boot密碼
- 群暉NAS忘記密碼如何重置密碼密碼
- PDF密碼忘記了,如何找回口令密碼密碼
- mysql 5.7忘記root密碼MySql密碼
- PbootCMS管理員密碼忘記怎麼辦?pboot重置密碼boot密碼
- Linux 忘記密碼Linux密碼
- 關於mysql忘記密碼的解決策略MySql密碼
- cobbler 忘記好系統登入密碼,如何修改cobbler部署機器的預設密碼密碼
- win10 mysql8.0.12 忘記root密碼如何重置密碼Win10MySql密碼
- MySQL——密碼管理MySql密碼
- 寶塔找回密碼:忘記密碼怎麼辦?密碼
- 修改Jenkins預設管理員admin密碼Jenkins密碼
- 修改BeEF工具預設密碼密碼
- MySQL 8.0.15忘記密碼重置方法MySql密碼
- iPhone忘記訪問限制密碼的解決辦法 密碼忘記了怎麼辦?iPhone密碼
- Mac之忘記管理員名和密碼Mac密碼
- 忘記網站管理員密碼的解決方法網站密碼
- 密碼安全:密碼設定要求,密碼爆破辦法,密碼歸類使用,密碼處置方案密碼
- ubuntu系統下mysql重置密碼和修改密碼操作UbuntuMySql密碼
- PbootCMS後臺登陸密碼忘記/找回密碼後臺登入密碼外掛boot密碼
- Mysql修改密碼之後,Navicat依然使用舊密碼連線問題MySql密碼
- Linux忘記root密碼解鎖Linux密碼
- macos下parallel Desktop 中centos忘記密碼及修改原使用者密碼MacParallelCentOS密碼
- 修改 MySQL 登入密碼MySql密碼
- mysql8.0修改密碼MySql密碼
- MySQL 8.0之後版本密碼修改MySql密碼
- 應用密碼學——古典密碼密碼學
- 分組密碼(一) — 密碼學複習(四)密碼學
- excel密碼忘記了怎麼解鎖 excel忘記密碼怎樣簡單找回Excel密碼
- Linux伺服器—mysql忘記密碼Linux伺服器MySql密碼
- MySQL密碼忘記後怎麼辦?MySql密碼
- mysql密碼忘記了怎麼辦MySql密碼