MySQL/MariaDB

How To Update The MYSQL Root Password

You can update the MySQL root password for the root user at any time by using an SSH console. The following guides details how this is achieved on CentOS, RedHat, Fedora, Debian and Ubuntu. First, stop the existing MySQL service by using the following commands

For CentOS, RedHat and Fedora Servers

service mysqld stop

For Debian and Ubuntu Servers

service mysql stop

Next, you need to restart the MySQL service with the —skip-grant-tables option using the following command

mysqld_safe --skip-grant-tables

Running MYSQL with the —skip-grant-tables is extremely insecure. Only do this for brief periods of time and only when absolutely necessary. The following steps will start MySQL in the usual way without this option loaded.

Now, log into MySQL with the following command mysql

Use the below command to set a new root password for MySQL. Replace NEW-PASSWORD with your new Mysql password.

UPDATE mysql.user SET Password=PASSWORD('NEW-PASSWORD') WHERE User='root';

Then issue the below command

FLUSH PRIVILEGES; exit;

Next, stop the MySQL service. You will be asked for your new MySQL root password at this point.

mysqladmin -u root -p shutdown

Finally, start the MySQL service in the normal way.

For CentOS, RedHat and Fedora Servers

service mysqld start

For Debian and Ubuntu Servers

service mysql start

You have now update your MySQL root password. Ensure you keep a secure copy of your MySQL root password or you may need to change it again. For details on installing MYSQL, PHP and Apache on CentOS6 you can use this guide.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button