How To Reset A Forgotten Root Password For MariaDB On CentOS 7


This first thing you need to do is stop the database server. Obviously your site will be down, but this is the only way to access the backdoor of the server to reset the password. To stop or shutdown MariaDB on CentOS 7, run the commands below.

# systemctl stop mariadb.service

Next, you need to start MariaDB with unrestricted access so you wouldn’t need password to sign on as the root user. This starts the database server in an insecure manner keeping it wide open to anyone.

Because the database is left wide open, you should safeguard against someone logging into the database remotely. This could happen, so add the –skip-networking option to the commands.

# mysqld_safe --skip-grant-tables --skip-networking &

Now that the database is started, you can now logon to it without passwords.

# mysql -u root

Once you’re logged-on, change to the mysql database. This database comes with all MySQL and MariaDB servers. It’s store encrypted credentials and privileges for the root user.

# use mysql;

Run the commands below to change the root password.

update user set password=PASSWORD("new-password") where User='root';
flush privileges;
Exit;

Start DB service 
# systemctl start mariadb.service

Verify 
# mysql -u root -p

How To Reset A Forgotten Root Password For MariaDB On CentOS 7 How To Reset A Forgotten Root Password For MariaDB On CentOS 7 Reviewed by vivek sathisan on 11:25 Rating: 5

No comments:

© Copyright to vivek sathisan. Powered by Blogger.