# Resetting a MySQL password

Category: [Dedicated servers / VPS](https://www.cloudvip.com/en/faq/dedicated-servers-vps.md)
Source page: [https://www.cloudvip.com/en/faq/dedicated-servers-vps/resetting-a-mysql-password](https://www.cloudvip.com/en/faq/dedicated-servers-vps/resetting-a-mysql-password)
Keywords: mysql, reset, password

The MySQL root password gives the root user full access to the MySQL database. 

You must have root access to the server to reset the MySQL root password.

Note: the server's root password is not the same as the MySQL root password. The server password grants access to the server. The MySQL root password grants access only to the MySQL database.

Follow these steps to reset a MySQL root password using the command-line interface.

Stop the MySQL service

(Ubuntu and Debian) Enter this command:

sudo /etc/init.d/mysql stop

(CentOS, Fedora, and Red Hat Enterprise Linux) Enter this command:

sudo /etc/init.d/mysqld stop

Start MySQL without a password:

Run this command. The ampersand (&) at the end of the command is required!

sudo mysqld_safe --skip-grant-tables &

Open a new terminal and connect to MySQL

Enter this command:

mysql -uroot

Enter this command:

use mysql;

update user set password=PASSWORD("mynewpassword") where User='root';

flush privileges;

quit

Stop the MySQL server

(Ubuntu and Debian) Enter this command:

sudo /etc/init.d/mysql stop

...

sudo /etc/init.d/mysql start

(CentOS, Fedora, and Red Hat Enterprise Linux) Enter this command:

sudo /etc/init.d/mysqld stop

...

sudo /etc/init.d/mysqld start

Test the new password by entering the following command:

mysql -u root -p

You are now logged in with your new password.
