MySQL 5.7遺忘root密碼重置記錄
摘要:MySQL 5.7設定root密碼方法update mysql.user set authentication_string=PASSWORD('****') where user='root' and host='localhost';
作業系統:
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.1.1503
MysQL版本5.7
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.9 |
+-----------+
1 row in set (0.00 sec)
安裝MySQL的yum repo源:
[root@localhost ~]# rpm -ivh
安裝MySQL
[root@localhost ~]# yum -y install mysql-community-server mysql-community-client
修改mysql 配置檔案跳過密碼驗證
[root@localhost ~]# vim /etc/my.cnf
[mysqld]
skip-grant-tables
skip-networking
重啟MySQL:
[root@localhost ~]# systemctl mysqld restart
匿名登入MySQL設定root密碼:
[root@localhost ~]# mysql -uroot -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.9 MySQL Community Server (GPL)
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> update mysql.user set PASSWORD=PASSWORD('test') where user='root' and host='localhost';
ERROR 1054 (42S22): Unknown column 'PASSWORD' in 'field list'
提醒:從5.7開始使用authentication_string不再使用password欄位存放密碼所以提示出錯。
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'test' ;
ERROR 1131 (42000): You are using MySQL as an anonymous user and anonymous users are not allowed to change passwords
檢視mysql.user表密碼欄位:
mysql>
desc mysql.user;
mysql> update mysql.user set authentication_string=PASSWORD('test') where user='root' and host='localhost';
Query OK, 1 row affected, 1 warning (0.07 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.06 sec)
mysql> select host,user,password from mysql.user;
mysql> exit;
Bye
取消跳過密碼認證:
[root@localhost ~]# vim /etc/my.cnf
[mysqld]
#skip-grant-tables
#skip-networking
重啟MySQL:
[root@localhost ~]# systemctl mysqld restart
必須使用alter user重置密碼:
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
重新設定新密碼:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '********'
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
密碼需要複雜度要求:
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_dictionary_file| |
| validate_password_length | 8 |
| validate_password_mixed_case_count| 1 |
| validate_password_number_count| 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count| 1 |
+--------------------------------------+--------+
6 rows in set (0.00 sec)
mysql> set password=password('xxxx');
Query OK, 0 rows affected (0.00 sec)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9034054/viewspace-2133407/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql 5.7忘記root密碼MySql密碼
- mysql5.7重置root密碼MySql密碼
- win10 mysql8.0.12 忘記root密碼如何重置密碼Win10MySql密碼
- MySQL 重置Root密碼MySql密碼
- MySQL 8.0.15忘記密碼重置方法MySql密碼
- MySQL 8.0 重置 root 密碼MySql密碼
- 教你怎麼解決MySQL 5.7及8.0版本資料庫的root密碼遺忘MySql資料庫密碼
- MySQL8.0 忘記 root 密碼下如何修改密碼MySql密碼
- Linux伺服器---mysql忘記root密碼Linux伺服器MySql密碼
- 記一次MySql重置root密碼無效MySql密碼
- MYSQL5.7 ROOT密碼修改教程MySql密碼
- MySql5.5忘記root密碼怎麼辦MySql密碼
- 07 . Jenkins忘記root密碼Jenkins密碼
- 在Linux中,如何重置 mysql root 密碼?LinuxMySql密碼
- Ubuntu重置root密碼Ubuntu密碼
- Ubuntu MySQL5.7設定root密碼UbuntuMySql密碼
- mysql 8.0忘記root使用者密碼處理MySql密碼
- PbootCMS忘記密碼後的重置密碼流程boot密碼
- 群暉NAS忘記密碼如何重置密碼密碼
- Linux忘記root密碼解鎖Linux密碼
- mysql 8 如何重置 root 使用者密碼MySql密碼
- mysql誤刪root使用者或者忘記root密碼解決方法MySql密碼
- CentOS7忘記mysql的root密碼_處理方法.CentOSMySql密碼
- CentOS 7.5 重置 root 密碼CentOS密碼
- Linux遺忘root密碼的其中兩種解決方法Linux密碼
- mysql 忘記密碼MySql密碼
- MySQL忘記密碼MySql密碼
- PbootCMS管理員密碼忘記怎麼辦?pboot重置密碼boot密碼
- 【問題處理】MySQL忘記root密碼的處理辦法MySql密碼
- win10平板忘記密碼如何解碼_平板win10忘記密碼強制重置Win10密碼
- rocky9如何重置root密碼密碼
- centos7的root密碼重置CentOS密碼
- 【轉載】Linux忘記root密碼--進入單使用者模式修改root密碼Linux密碼模式
- centos7 修改root密碼 密碼忘記的情況下CentOS密碼
- 破解 MySQL5.7 資料庫的 root 登入密碼MySql資料庫密碼
- linux破解root登入密碼,並重置Linux密碼
- Tool-Gitlab-重置root賬戶密碼Gitlab密碼
- linux系統root密碼忘記了怎麼辦Linux密碼
- mysql忘記密碼解決方案MySql密碼