2018.6.1
MySQL database forgot root password resolved:
- Enter configuration file/etc/my.cnf
- Add a statement under [mysqld]: Skip-grant-tables
- Restart Mysqld:service mysqld Restart
- Login MySQL database without password: mysql-uroot-p
Operation after entering the database:
Using the MySQL Librarymysql> use MySQL;
Reading table information for completion of table and column names
Can turn off this feature to get a quicker startup with-a
Database changed
Be sure to check the User password field name clearlyMysql> SELECT * from user limit 1\g;
1. Row *********************
Host:localhost
User:root
Select_priv:y
... (Omitted here)
Plugin:mysql_native_password
Auther_string: *81f5e21e35407d884a6cd4a731aebfb7af209e1b
# This string of characters is the encrypted password, select its field name
Password_expired:n
Password_last_changed:2018-05-31 15:12:34
Password_lifetime:null
Account_locked:n
1 row in Set (0.00 sec)
Change Password:
mysql> Update user set Auther_string=password (' 123 ') where user= ' root ';
Query OK, 1 row affected, 1 Warning (0.00 sec)
Rows matched:2 changed:1 warnings:1
- Log out of the database after successful modification, comment out the password-free login in the configuration file
- Restart mysqld: [[email protected] ~]# systemctl Restart Mysqld
Verification: [[email protected] ~]# mysql-uroot-p123
MySQL database forgot root password resolved