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
Replies
0
Views
24
Replies
1
Views
38
Replies
0
Views
227
Replies
1
Views
49
Recommended Threads
Replies
7
Views
1,699
Replies
9
Views
2,228
fwh
Replies
8
Views
3,179
Replies
0
Views
703

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