Change MySQL password on Linux CentOS


security-2168233_640

First of all, make sure there is no empty passwords by using these commands via SSH;


mysql -u root

SELECT User, Host, Password FROM mysql.user;

To change any user’s password, issue these commands via SSH;


sudo systemctl stop mariadb.service

killall -9 mysqld mysqld_safe

sudo mysqld_safe --skip-grant-tables &

sudo systemctl restart mariadb.service

(you may need to press ENTER twice)

mysql -u root mysql

SELECT Host, User FROM mysql.user;

UPDATE user SET Password=PASSWORD('your_new_password') where USER='The_user_@_localhost';

FLUSH PRIVILEGES;

quit

sudo systemctl restart mariadb.service

mysql -u root -p

 

Alternately, use this command;

/usr/bin/mysqladmin -u root password 'new password'

Leave a Reply

Please log in using one of these methods to post your comment:

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 )

Connecting to %s