MySQL MariaDB – Resetting a lost MySQL root password

Stop MySQL

Ubuntu,  Debian /etc/init.d/mysql stop

 CentOS, Fedora, and RHEL /etc/init.d/mysqld stop

CentOS 7 systemctl stop mariadb.service

check if mysql or mysql_safe is running

ps -e | grep mysql

Safe mode

sudo mysqld_safe –skip-grant-tables –skip-networking &

Login

mysql -uroot

.>use mysql;

Reset Password

.>update user set password=PASSWORD(“mynewpassword”) where User=’root’;

.> flush privileges;

.>quit;

Restart

/etc/init.d/mysql stop
...
/etc/init.d/mysql start
...
start mariadb.service
This entry was posted in Database MySQL or MariaDB. Bookmark the permalink.

Leave a Reply