Useful shortcuts for vi editor

Wednesday 20 November 2019

How to reset mariadb root password on using Galera Cluster system?

e.g. reset root password
two machines in a cluster

1st step:

-> Activate "safe_to_bootstrap" parameter on first machine
# vi /var/lib/mysql/grastate.dat
safe_to_bootstrap: 1

2nd step on first/second machine:
# systemctl stop mariadb

3rd step:

-> Run database in safe mode on first machine
# /usr/bin/mysqld_safe --skip-grant-tables --wsrep-new-cluster "${@:2}" > /dev/null 2>&1 & 

4th step:

-> Note the process id of mysql service
# ps -ef | grep mysql

5th step:

-> Connect mysql terminal then run following commands on first machine
# mysql -u root
 use mysql;
 update user SET PASSWORD=PASSWORD("password") WHERE USER='root';
 flush privileges;
 exit

6th step:

-> Try to connect with new password on first machine
# mysql -u root -ppassword

7th step:
-> kill the odd service on first machine
# kill -9 1111

8th step:
-> Start new cluster on first machine
# galera_new_cluster

9th step:

-> Start mariadb on second machine
systemctl start mariadb

Done...

Ref:

https://robbinespu.github.io/eng/2018/03/29/Reset_mariadb_root_password.html
https://blog.toonormal.com/2015/11/23/mariadb-cluster-install-notes/