Simple method to reset MySQL or MariaDB root password in CLI
To reset your MySQL root password in SSH, simply run the following sequence of commands:
/etc/init.d/mysqld stop
mysqld_safe --skip-grant-tables &
mysql -u root
use mysql;
update user set password=PASSWORD("newrootpassword") where User='root';
flush privileges;
quit
/etc/init.d/mysqld stop
/etc/init.d/mysqld start
On Fedora 7.x based systems, which come with MariaDB instead of MySQL, run:
systemctl stop mariadb
mysqld_safe --skip-grant-tables &
mysql -u root
use mysql;
update user set password=PASSWORD("newrootpassword") where User='root';
flush privileges;
quit
systemctl stop mariadb
systemctl start mariadb
Add new comment