"MySQL Series - Deployment and Maintenance" How to retrieve the password correctly for MySQL8.0 version?

MySQL8.0 retrieve password

1. The MySQL8.0 service is deployed on the Windows server, and the password needs to be retrieved. But according to the conventional method, my.iniadding skip-grant-tablesparameters to the file and restarting MySQL did not take effect

C:\Users\EDZ>mysql -uroot -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost:3306' (10061)

2. After data search, the following methods are adopted:

Tried mysqld --skip-grant-tablesthe command, but still can't log in without password

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

D:\software\MySQL\mysql-8.0.27-winx64\bin>mysqld --console --skip-grant-tables --shared-memory
2023-03-28T09:00:39.296919Z 0 [Warning] [MY-000081] [Server] option 'wait_timeout': unsigned value 31536000 adjusted to 2147483.
2023-03-28T09:00:39.297172Z 0 [System] [MY-010116] [Server] D:\software\MySQL\mysql-8.0.27-winx64\bin\mysqld.exe (mysqld 8.0.27) starting as process 15764
2023-03-28T09:00:39.313331Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-03-28T09:00:39.715547Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-03-28T09:00:40.031200Z 0 [Warning] [MY-011311] [Server] Plugin mysqlx reported: 'All I/O interfaces are disabled, X Protocol won't be accessible'
2023-03-28T09:00:40.112717Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2023-03-28T09:00:40.112899Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2023-03-28T09:00:40.115167Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-03-28T09:00:40.115372Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-03-28T09:00:40.137087Z 0 [System] [MY-010931] [Server] D:\software\MySQL\mysql-8.0.27-winx64\bin\mysqld.exe: ready for connections. Version: '8.0.27'  socket: ''  port: 0  MySQL Community Server - GPL.

3. Restart and open a DOS window, and you can log in without password. After logging in, you can close the DOS window just started by mysqld. After changing the password, log in again

C:\Users\EDZ>mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.27 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> flush privileges;
Query OK, 0 rows affected (0.03 sec)


mysql> alter user 'root'@'localhost' identified by 'Zxy@123456';
Query OK, 0 rows affected (0.01 sec)

Guess you like

Origin blog.csdn.net/m0_51197424/article/details/129824504