MySQL 8.0 modify login password

1. Enter the original password to enter the database

insert image description here

Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.28 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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.

2.show databases;

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| ascent             |
| ascentweb          |
| blog               |
| bookshop           |
| chapter04          |
| chapter06          |
| chat               |
| chitchat           |
| db_database24      |
| go_web             |
| information_schema |
| jdbc               |
| manager            |
| mysql              |
| performance_schema |
| shop               |
| shoppingweb        |
| spj                |
| sqlexp-sztuoj      |
| sys                |
+--------------------+
20 rows in set (0.00 sec)

3.use mysql;

mysql> use mysql;
Database changed

4. Change password

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';  

5. Log out and log in with the new password

Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.28 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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.

Guess you like

Origin blog.csdn.net/weixin_51571728/article/details/127810465