Forgotten root mysql password
Getting the MySQL root password back is diffiicult (sha-1 hash).
Resetting the password is a better solution.
The below instructions are known to work with Bright 7.3, 8.0, 8.1, 8.2
CentOS 7 instructions:
To do a reset of the password, stop all applications that use the MySQL service during the reset operation. Stop the mysql service and start it in safe mode during the reset.
The following commands on the head node (tested for CentOS 7) show how such a reset session can be carried out:
# systemctl stop mariadb.service
# mysqld_safe --skip-grant-tables &
# mysql -u root
MariaDB [(none)]> use mysql;
MariaDB [(none)]> update user set password=PASSWORD("newpass") where
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> quit
# pkill mysqld_safe
# systemctl start mariadb.service
Ubuntu 16.04 instructions:
# systemctl stop mysql
# mkdir /var/run/mysqld
# chown mysql.mysql /var/run/mysqld
# mysqld_safe --skip-grant-tables
mysql> flush privileges;
mysql> alter user 'root'@'localhost4' identified by 'MyNewPass'
Once password has been changed, kill the mysql and mysqld_safe processes and start the mysql service again.
# systemctl start mysql