Recent Posts

How to change/update MySQL password in Linux/Command Line

For changing MySQL password you should follow some steps:

1.Open your terminal and type:

 >service mysql start
 >mysql -u root -h localhost -p
 -u(user name,here username is root)
 -h(hostname localhost)
 -p(password if you haven't save any password then click enter button)

if you save password in mysql then type:
 > SET PASSWORD FOR 'root'@'localhost' = PASSWORD('asyourwish');


If you don't set any password then keep it empty like this:
 > SET PASSWORD FOR 'root'@'localhost' = PASSWORD('');

Here if you want you write all queries should be lower case.

OR
 > UPDATE mysql.USER SET Password=PASSWORD('asyourwish') WHERE USER='root' AND Host='localhost';

If you don't set any password then keep it empty like this:
 > UPDATE mysql.USER SET Password=PASSWORD('') WHERE USER='root' AND Host='localhost';

Then type:
 > exit

If you face any problem in MySQL then type:
 > service mysql restart

Post a Comment

0 Comments