[root@192 mysql]# systemctl start mysqld[root@192 mysql]# mysql -uroot -p
Enter password:
ERROR 1045(28000): Access denied for user 'root'@'localhost'(using password: NO)[root@192 mysql]# grep password /var/log/mysqld.log 2024-01-13T14:41:18.629566Z 6[Note][MY-010454][Server] A temporary password is generated for root@localhost: <da01yybd;0K
5.登陆MySQL,修改用户密码
[root@192 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.35
Copyright (c)2000, 2023, 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> show databases;
ERROR 1820(HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user 'username'@'localhost' identified by '#Yk123456';# 修改用户密码
ERROR 1820(HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user 'root'@'localhost' identified by '#Yk123456';
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema || mysql || performance_schema || sys |
+--------------------+
4 rows inset(0.01 sec)