1. FIND ROOT USERNAME

The root username is always root.

2. HOW TO CHANGE DEFAULT ROOT PASSWORD

Connect to your server, using command line (terminal), then run:

Stop MySQL:

If you are using Ubuntu or Debian:

sudo /etc/init.d/mysql stop

For CentOS, Fedora, and RHEL:

sudo /etc/init.d/mysqld stop

Start MySQL in safe mode:

sudo mysqld_safe --skip-grant-tables &

Login (without any password):

 mysql -u root

Select the database:

 use mysql;

Change password:

 update user set password=PASSWORD("YOUR NEW PASSWORD HERE") where User='root';

Flush Privileges (a refresh for privileges):

 flush privileges;

Exit:

 quit

or

 exit

Restart MySQL:

Ubuntu and Debian:

sudo /etc/init.d/mysql stop

and

sudo /etc/init.d/mysql start

CentOS, Fedora and RHEL:

sudo /etc/init.d/mysqld stop

and

sudo /etc/init.d/mysql start

Password changed successfully!

Now, you can try to login with the new password:

mysql -u root -p

(type the password when prompted)

Success!

Last modified: May 8, 2021

Author