In this section, we will discuss several scenarios and how to deal with them:

To reset root password, we have to stop the MySQL and start it without the grant tables, change the password and then restart.

Reset Root password

[root@mysql-cluster-b ~]# systemctl stop mysqld.service   
[root@mysql-cluster-b ~]# mysqld --skip-grant-tables --user=mysql &
[1] 24010
[root@mysql-cluster-b ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.37 MySQL Community Server - GPL

Copyright (c) 2000, 2024, 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.01 sec)

mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Secret123#';
Query OK, 0 rows affected (0.00 sec)

mysql> ^DBye
[root@mysql-cluster-b ~]# systemctl restart mysqld.service

Simple as that.

  • mysql8_management.txt
  • Last modified: 2024/06/18 20:42
  • by andonovj