Change MySQL password on Linux CentOS


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';



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: Logo

You are commenting using your 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