ALERT: Some images may not load properly within the Knowledge Base Article. If you see a broken image, please right-click and select 'Open image in a new tab'. We apologize for this inconvenience.

Broadcom - Gateway 10.x Appliance : How to reset Database Root password in MySQL 8.x

book

Article ID: 237226

calendar_today

Updated On:

Products

CA API Gateway

Issue/Introduction

Unable to access MySQL console as ROOT due to lost and/or unknown password. 

Attempted to reset the password by following the below KB article, however, it appears not working with MySQL 8.x version.

https://knowledge.broadcom.com/external/article/92946/how-to-reset-mysql-internal-root-passwor.html

Cause

The procedure to reset DB Root password is slightly different in MySQL 8.x from what used to be in MySQL 5.x.

Environment

Release : 10.0

Component :

Resolution

Start MySQL service with the --skip-grant-tables option and alter the ROOT password with the following steps:

  • First, make sure that the MySQL service is stopped.

# systemctl stop mysqld.service   

  • Then start MySQL service with the following options appended into the command line:

# mysqld --skip-grant-tables --user=mysql &

  • At this stage, you should be able to connect MySQL console (without entering credentials) by simply running:

# mysql

  • When MySQL service is started with --skip-grant-tables option, account-management is disabled and we must reload the grants in order to alter the password. In order to do so, reload users privileges:

# FLUSH PRIVILEGES;

  • At this stage, we can use the following query to update the ROOT password. Replace “new_password” with the actual password you desire to use

# ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

  • Stop MySQL service and start it back as in normal circumstances:

# systemctl stop mysqld.service   

# systemctl start mysqld.service   

 

Additional Information

Please, do not forget to update /root/.my.cnf file with the new password if you store it under the OS user profile.