How to Reset MySQL Root User Password on Ubuntu 22.04

[ad_1]

If you are using MySQL database, and have forgotten its root user’s password or want to reset it for some reason. For this, you have to use 3 commands of mysql such as sudo systemctl set-environment MYSQLD_OPTS=”–skip-networking –skip-grant-tables”, flush privileges;, mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘(YOUR_NEW_PASSWORD)’;, and you can easily reset the password of your root user on Ubuntu.

Here are some steps to reset MySQL root user password on Ubuntu 22.04 or 20.04 systems:

Step 1: Stop MySQL Server

To reset the MySQL root user password, you first need to shut down the MySQL server, for this you can use the systemctl command:

sudo systemctl stop mysql.service

Step 2: Skip Grant Tables and Networking

To access MySQL server without valid password, you need to skip grant tables and networking validation, for this you can use this command:

Ezoic

sudo systemctl set-environment MYSQLD_OPTS="--skip-networking --skip-grant-tables"

The MySQL environment has been configured to use it without a password. Now, can log in to MySQL server without password.

Step 3: Start MySQL Server

Now the MySQL server has to be started so that the password can be reset, for this you can use the command:

Ezoic

sudo systemctl start mysql.service

Step 4: Log in as a MySQL Root User

To access MySQL Server and its service as root user without password, Type this command on terminal and you can log in to MySQL Server:

sudo mysql -u root

Step 5: Reset MySQL Root User Password

To select a MySQL database and flush privileges on terminal window, you use the “use mysql” and “flush privileges;” command:

Ezoic

flush privileges; use mysql;

To set a new password for the MySQL root user on, you need to use the MySQL alter command, type this command on a ubuntu terminal window:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '(YOUR_NEW_PASSWORD)';

Here, your_new_password in command, change it to your new password. And then exit the mysql shell by using this exit command:

Exit;

Ezoic

Step 6: Stop all MySQL processes and restart the MySQL server

Once the root password is set, the changes made can be applied. For this, stop or stop all the MySQL server processes and restart the server, you can do this by:

To stop mysql proccesses:

sudo killall -u mysql

To restart mysql server:

Ezoic

sudo systemctl restart mysql.service

Step 7: Log in to MySQL With New Password

With the steps you’ve followed so far, the new password for your MySQL root user has been set. Now, you can login into MySQL server as root user with the new password, you can use:

sudo mysql -u root -p

Here is the video guide on how to reset MySQL root user password on ubuntu:

Conclusion

That’s it; you have a detailed tutorial explaining everything step by step, using which you can reset the MySQL root user password ubuntu 22.04 easily.

Ezoic

Recommended Tutorials

Ezoic

[ad_2]

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

GSTIN is 03EGRPS4248R1ZD.

Contact
Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00