Mysql 8.0.26 Forget the login password solution, step-by-step tutorial, detailed!

0. Run cmd as administrator

1. Stop the mysql service, enter the following command and press Enter

net stop mysql

2. Skip the verification password, enter the following command and press Enter

mysqld --console  --skip-grant-tables --shared-memory

3. Run the new cmd as an administrator, enter the following command and press Enter

mysql -u root -p

4. When the password is required to be entered, skip it directly and press Enter

5. Modify the password
5.1 Enter the database
Enter the following command and press Enter

use mysql;

5.2 Refresh permissions
Enter the following command and press Enter

flush privileges;

5.3 Clear the original password
Enter the following command and press Enter

update user set authentication_string=''  where user='root';

5.4 Refresh permissions again
Enter the following command and press Enter

flush privileges;

5.5 Change to a new password (if 5.5 is unsuccessful, execute 5.4 several times)
Enter the following command and press Enter, (this 123456 can be changed to your own password, the password format can be a combination of uppercase and lowercase letters + numbers + special characters)
PS: If you changed localhost to % for remote connection, then change it to 'root'@'%'

alter user 'root'@'localhost' identified by '123456';

6. Exit the database,
enter the following command and press Enter

quit

7. Log in to the database with the new password, enter the following command and press Enter

mysql -u root -p

8. Enter the password and press Enter

123456

After successfully entering the database, you can use a database connection tool such as Navicat to connect to the database with an account (such as root) and a password (such as 123456). The specific case is as follows:
Follow steps 7 and 8 above
7. Command line input: mysql --version
8. Input: mysql -uroot -p, fill in the password, and enter mysql.
9. View the existing database
input:

show databases;

View existing database
10. Use Navicat to connect to the Mysql database
10.1 Open Navicat, click File, create a new connection, select MySQL
insert image description here
10.2, enter the connection name (custom) and password, and then test whether the connection is successful.
The password here is the newly reset login password, which is now: 123456
insert image description here
10.3 After the test connection is successful, click OK
insert image description here
10.4 Right-click test, click Open Connection, and view the database.
insert image description here
10.5 Screenshot of successful connection.
insert image description here

Guess you like

Origin blog.csdn.net/yzq199902/article/details/131903333