MySQL 8.0修改登录密码

1.输入原密码进入数据库

MySQL 8.0修改登录密码_第1张图片

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.修改密码

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

5.退出,使用新密码登录

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.

你可能感兴趣的:(DataBase,mysql,数据库)