MySQL 修改登录密码

  • Post author:
  • Post category:mysql


参考:

MySQL的安装与配置——详细教程


这里直接上图:

在这里插入图片描述

具体操作和分析如下:

(c) Microsoft Corporation。保留所有权利。

C:\WINDOWS\system32>d: //跳到D盘

D:\>cd D:\mysql\mysql-8.0.26-winx64\mysql-8.0.26-winx64\bin   //跳到D盘中的mysql下的bin目录

D:\mysql\mysql-8.0.26-winx64\mysql-8.0.26-winx64\bin>mysqld --initialize --console //初始化mysql(会产生随机密码,在本句运行结果的结尾)
2022-07-13T00:53:38.987785Z 0 [System] [MY-013169] [Server] D:\mysql\mysql-8.0.26-winx64\mysql-8.0.26-winx64\bin\mysqld.exe (mysqld 8.0.26) initializing of server in progress as process 8588
2022-07-13T00:53:38.988771Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2022-07-13T00:53:39.045319Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-07-13T00:53:46.582556Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-07-13T00:54:04.736489Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2022-07-13T00:54:04.737282Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2022-07-13T00:54:04.817255Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: v&o.!JeW_2<f  //随机密码

D:\mysql\mysql-8.0.26-winx64\mysql-8.0.26-winx64\bin>net start MySQL //开启mysql服务
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。


D:\mysql\mysql-8.0.26-winx64\mysql-8.0.26-winx64\bin>mysql -u root -p  //登陆验证
Enter password: ************  //输入刚刚产生的随机密码
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.26

Copyright (c) 2000, 2021, 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.

mysql> alter user 'root'@'localhost' identified by '123456';  //修改密码
Query OK, 0 rows affected (0.16 sec)  //修改密码成功

mysql> \q //退出
Bye

D:\mysql\mysql-8.0.26-winx64\mysql-8.0.26-winx64\bin>mysql -u root -p //登录 验证新密码
Enter password: ******  //登录新密码
Welcome to the MySQL monitor.  Commands end with ; or \g.  //登录成功
Your MySQL connection id is 9
Server version: 8.0.26 MySQL Community Server - GPL

Copyright (c) 2000, 2021, 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.

mysql> \q  //推出
Bye

D:\mysql\mysql-8.0.26-winx64\mysql-8.0.26-winx64\bin>



版权声明:本文为Liu_wen_wen原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。