Skip to main content
IT BIBLESign in

Forum / Servers / Server Software

How to reset my sql root password ?

at54tl OP
Apr 15, 2023, 9:33 PM UTC
#1

Hello everyone,

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

Thank you

WizardTux Cool Guy
Apr 15, 2023, 9:43 PM UTC
#2

at54tl wrote:

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.

# 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

Sign in to reply.