Board logo

subject: 2 Ways to Change or Update Mysql Root Password [print this page]


2 Ways to Change or Update Mysql Root Password

I worked in a technical company and always found that the client lost or forgot the mysql password. Therefore, I would like to share the steps to change or update the mysql password.

Solution 1)

Forgot your password? Want to change your mysql root password under under Linux, FreeBSD, OpenBSD and UNIX like operating system over ssh / telnet session?

After the operation system installed completely, there are null for mysql root password. Therefore, you need to set the root password for first time by typing:

# mysqladmin -u root password YOURNEWPASSWORD

Sometimes, you need to change or update your mysql root password, then you could use this command:

# mysqladmin -u root -p'YOURNEWPASSWORD' password 'YURNEWPASSWORD'

But, How can we change dedicate use password?

e.g you wan to change mysql password for user techutter

# mysqladmin -u techutter -p 'TECHUTTEROLDPASSWORD' password 'TECHUTTERNEWPASSWORD'

Solution 2)

The mysql user, passwd and permission information stored in mysql database.

Therefore, you can change the informaion by update the mysql table:

- First, Login to the mysql with root:

#mysql -u root -p

- Second, Use the mysql database:

mysql> use mysql;

- Third, For example, you want to change techutter password

mysql> update user set password=PASSWORD("TECHUTTERNEWPASSWORD") where User='techutter';

- Finally, type the following command to Reload privileges and quit the mysql server:

mysql> flush privileges;

mysql> quit

TESTING:

Now you can use the new password for the techtter user to login the mysql for testing:

mysql -u techutter -p TECHUTTERNEWPASSWORD

Do you want extra technical tips? If Yes! Then,Click Here to visit my website "Techutter " now




welcome to loan (http://www.yloan.com/) Powered by Discuz! 5.5.0