How to change password for MySQL on Linux

Maxoq

Well-known member
Registered
Joined
Feb 25, 2015
Messages
520
Points
28
When I tried to login to mysql via ssh, I could not remember root password and I got this message

Access denied for user ‘root'@'localhost'
I want to root password for MySQL on Linux, how to do that?
 

MooseLucifer

Well-known member
Registered
Joined
May 20, 2016
Messages
149
Points
28
@Max

Following these ways to change your mysql password

1. Turn off the MySQL server:

Code:
mysql stop service
If the command above did not turn off the MySQL service, you can use the command below

Code:
killall mysql
2. Turn on MySQL in safe mode

Code:
mysqld_safe --skip-grant-tables
3. Change the MySQL root password


Code:
mysql -u root -p
Code:
mysql> USE mysql;
mysql> UPDATE user SET password = PASSWORD(new_password”) WHERE User = ‘root';
you replace new_password with your new password.

4. Turn off safe mode of MySQL

Code:
killall mysqld_safe
5. Turn on MySQL in normal mode.

Code:
sudo service mysql start
Now you have completely changed the password for user root MySQL, keep it for you and don't forget it again then.

Good luck!
 
Latest Threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top