How to change MySQL root Password in CentOS/RedHat/Fedora and Unix like Operating Systems

There are generally 2 method to change MySQL root User password:

I:-Use mysqladmin command to change MySQL root user password.

II:-Using the mysql command to change MySQL root user password.

 I:-Use mysqladmin command to change MySQL root user password:

If you haven’t set a root password for MySQL server, then server does not require a password to enter in the root user. To setup root password for first time, use mysqladmin command at shell prompt as shown bellow.

  Syntax: mysqladmin -u root password NEWPASSWORD

if you want to change a root password, then you use mysqladmin command

Syntax: mysqladmin -u root -p’oldpassword’ password newpassword

 In the above live Example “system@123” is old password and “adcd@123” is new password

II:-Using the mysql command to change MySQL root user password

 This is an another method to change MySQL root user password. Generally MySQL store username and password  in user table inside the mysql database. whole process to change MySQL root password with mysql command shown bellow figures.

In the above live example changed password is “system@123” and now we access MySQL with this password.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s