How to reset my sql root password ?

  • Welcome to ITBible, we're your #1 resource for enterprise or homelab IT problems (or just a place to show off your stuff).

at54tl

Well-known member
TCC-OG
Mar 19, 2023
10
1
1
104
Hello everyone,

I forgot the root password to mysql server , is there any to reset it ?

Thank you
 
Hello everyone,

I forgot the root password to mysql server , is there any to reset it ?

Thank you
Should be able to do the following.

Bash:
# stop the mysql service
> systemctl stop mysql
# launch the service without grant-tables and networking (to the background)
> /usr/sbin/mysqld --skip-grant-tables --skip-networking &
# login to mysql as root
> mysql -u root
# flush privileges
mysql> FLUSH PRIVILEGES;
# set the root password
mysql> SET PASSWORD FOR root@'localhost' = PASSWORD('itbible');
# exit back to bash
mysql> quit
# kill the running session that you launched to the background
> kill %1
# start normally again
> systemctl start mysql

obviously you should change the password to something other than 'itbible' :p