In this articel we will learn to change MySQL root password through WHM or SSH. Things to check, you must have root access for your server. This facility is available for Dedicated servers only and not for shared server users. MySQL root password is separate from main user root password. Now, we will check all ways through which we can accomplish our task for MySQL root password change.

1). Through WHM : You can change MySQL root password through WHM. You have to follow these steps :
  • Login to WHM as root
  • Check for category "SQL Services" in the left pane and click on it. Then click on "MySQL Root Password".
  • You will be redirected on screen where you will find option to fill new password. You can enter your new password or you can generate a password through password generator. Now click on "Change Password".
  • You will get a prompt screen for successful password changed.

2). Through mysqladmin command : You can change MySQL password through SSH also. first, we will learn through mysqladmin command. First you have to login as root through SSH.
Now to change password run this command :
-----
# mysqladmin -u root -p oldpassword password newpassword //Syntax
# mysqladmin -u root -p Harry%007 password James@007 //Example

-----
here, "Harry%007" is old password and we have changed it to "James@007".

3). Through mysql command : You can change MySQL root password through mysql command also. We have to follow these below given commands.
First, we have to stop MySQL services on server before proceeding further.

To stop MySQL services run this command :
-----
# sudo /etc/init.d/mysql stop
-----

Now start MySQL without a password :
-----
# sudo mysqld_safe --skip-grant-tables &
-----
Ampersand (&) is required at the end of this command.

then, connect MySQL through this command :
-----
# mysql -u root
-----

Now run these commands to change MySQL root password :
-----
# use mysql;
# update user set password=PASSWORD("newpassword") where User='root';
# flush privileges;
# quit

-----

Now, stop and start MySQL services again through these commands :
-----
# sudo /etc/init.d/mysqld stop
# sudo /etc/init.d/mysqld start

-----
Author
bhawanisingh
Views
2,574
First release
Last update
Rating
0.00 star(s) 0 ratings
Top