/sc_assets/3664/logo.png

Select a topic:

Choose from one of the topics below to browse other articles

Ubuntu

Articles & Information.

Changing the MySQL root password

This guide is for Ubuntu, but you should be able to find similar commands on most platforms.

There are many reasons why you might want to change your MySQL root password, but fortunately it's fairly straightforward to do. Just SSH into your server and do the following:

  1. Stop the MySQL server: service mysql stop
  2. Start the mysqld configuration: sudo mysqld --skip-grant-tables &
  3. Log in as root: mysql -u root mysql
  4. Run the following SQL command to change your password:
UPDATE user SET Password=PASSWORD('YourNewPasswordHere') WHERE User='root'; FLUSH PRIVILEGES; exit;

And that's it! Your root password will be changed.