Reset a MySQL root password

Use the following steps to reset a MySQL root password by using the command line interface.

Stop the MySQL service

(Ubuntu and Debian) Run the following command:

(CentOS, Fedora, and Red Hat Enterprise Linux) Run the following command:

Start MySQL without a password

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

Connect to MySQL

Run the following command:

Set a new MySQL root password

Run the following command:

Stop and start the MySQL service

(Ubuntu and Debian) Run the following commands:

(CentOS, Fedora, and Red Hat Enterprise Linux) Run the following commands:

Log in to the database

Test the new password by logging in to the database.

You are prompted for your new password.

Reset a MySQL root password
4.5 (90%) 4 vote[s]