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 operating system 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 operating system 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.
Enter your new password when prompted.