# How to reset my sql root password ?

**URL:** <https://community.itbible.org/t/how-to-reset-my-sql-root-password/738>\
**Category:** Server Software\
**Created:** [April 15, 2023, 9:33pm UTC](https://community.itbible.org/t/how-to-reset-my-sql-root-password/738 "2023-04-15T21:33:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![at54tl](https://community.itbible.org/user_avatar/community.itbible.org/at54tl/32/85_2.png) [@at54tl](https://community.itbible.org/u/at54tl)\
**Post date:** [April 15, 2023, 9:33pm UTC](https://community.itbible.org/t/how-to-reset-my-sql-root-password/738/1 "2023-04-15T21:33:03Z")

</div>

Hello everyone,

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

Thank you

---

<div class="post-metadata">

**Author:** ![WizardTux](https://community.itbible.org/user_avatar/community.itbible.org/wizardtux/32/4_2.png) [@WizardTux](https://community.itbible.org/u/WizardTux)\
**Post date:** [April 15, 2023, 9:43pm UTC](https://community.itbible.org/t/how-to-reset-my-sql-root-password/738/2 "2023-04-15T21:43:34Z")

</div>

> [@at54tl](#):
>
> 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’ 😛

---

<div class="post-metadata">

**Author:** ![at54tl](https://community.itbible.org/user_avatar/community.itbible.org/at54tl/32/85_2.png) [@at54tl](https://community.itbible.org/u/at54tl)\
**Post date:** [April 16, 2023, 12:06pm UTC](https://community.itbible.org/t/how-to-reset-my-sql-root-password/738/3 "2023-04-16T12:06:19Z")

</div>

That almost worked but I tried doing this and it did the trick:

```bash
sudo /usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf

```

```mysql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';

```

Thanks,  
Source: [https://askubuntu.com/questions/1240542/how-can-i-reset-mysql-server-8-0-root-password-on-ubuntu-20-04/1295497#1295497](https://askubuntu.com/questions/1240542/how-can-i-reset-mysql-server-8-0-root-password-on-ubuntu-20-04/1295497#1295497)  
Cheers!
