Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

The Root MySQL Password on Your Dedicated Server

This guide explains what the MySQL root password is and how to use, find and reset it. It needs root access to your server.

Databases2 min read11 steps
Note: This guide needs root access. VPS and dedicated server customers have it. Shared hosting customers do not.

What is the MySQL root password?

MySQL is a database system. A database is a store for your website's information.

The MySQL "root" user is the boss account. It can see and change every database on the server. Its password is the key to all of them.

This is not the same as your server's root login. The server root login opens the whole computer. The MySQL root account only opens the databases. They can have different passwords.

Is there a password already?

On servers with cPanel/WHM, the system saves the MySQL root password in a hidden file. On a plain server, it may be empty or set during setup. Check your welcome email, or ask Hostvento support.

Test your login

  1. Connect to your server with SSH. SSH lets you type commands on the server.
  2. Type this command:
mysql -u root -p

This tries to log in as the MySQL root user. It then asks for the password.

  1. Type the password and press Enter. You will not see the letters as you type. That is normal.
  2. If you see mysql>, you are in. Type exit to leave.

Check the saved password on cPanel servers

  1. Connect with SSH as root.
  2. Look at the file that holds the saved login:
cat /root/.my.cnf

This shows the saved MySQL root login. Do not share what you see.

Reset a lost password

Warning: this briefly stops your databases, so websites will show errors. Do it at a quiet time and take a backup first.

  1. Stop MySQL:
    systemctl stop mysqld
    Some servers name the service mariadb or mysql.
  2. Start it without password checks:
    mysqld_safe --skip-grant-tables &
  3. Log in with no password:
    mysql -u root
  4. Run these lines, using your own new password:
    FLUSH PRIVILEGES;
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewStrongPassword';
    FLUSH PRIVILEGES;
    EXIT;
  5. Stop the safe mode process, then start MySQL the normal way:
    systemctl restart mysqld

On cPanel/WHM servers, you can also change it in WHM. See the guide on changing the MySQL root password via WHM.

Tip: Use a long, hard-to-guess password. Keep it in a safe place and never email it.

Quick recap

  • The MySQL root user controls all databases on the server.
  • Its password is not the same as your server root login.
  • Test it with mysql -u root -p.
  • Reset it carefully, after a backup, if you lose it.