In this article we will cover the steps to reset mysql 8 root password on ubuntu 20.04 LTS. So please follow the steps carefully and in order to make the process easier and smooth.

Introduction:

MySQL is a widely-used relational database management system. If you’ve forgotten the root password for your MySQL 8 installation on Ubuntu 20.04 LTS, don’t worry; we’ll walk you through the steps to reset it.

Prerequisites:

Before you begin, make sure you have:

  1. Access to a terminal on your Ubuntu 20.04 LTS server.
  2. Sudo privileges or access to the root user account.

Steps of “How to Reset MySQL 8 Root Password on Ubuntu 20.04 LTS?”

Let’s start the steps to Reset MySQL 8 Root Password on Ubuntu 20.04 LTS. Please follow steps in order.

Step #1: Stop MySQL Service

Before resetting the MySQL root password, stop the MySQL service:

ubuntu@Rushi-InfoTech:~$ sudo systemctl stop mysql

Step #2: Start MySQL in Safe Mode

Start MySQL in safe mode, which allows you to bypass authentication and make changes to user accounts:

ubuntu@Rushi-InfoTech:~$ sudo mysqld_safe --skip-grant-tables --skip-networking &

Hit ‘ENTER’ to return to your terminal.

Step #3: Access MySQL

Connect to the MySQL server without a password:

ubuntu@Rushi-InfoTech:~$ sudo mysql -u root mysql

You successfully entered into the mysql database without password.

Step #4: Change MySQL Root Password

Please Execute following command:

mysql> UPDATE mysql.user SET authentication_string=null WHERE User='root';

Flush the privileges.

mysql> FLUSH PRIVILEGES;

In the MySQL shell, use the following SQL command to reset the root password. Replace ‘Rushi@123’ with your desired new password:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Rushi@123';

Replace ‘Rushi@123’ with your chosen password within single quotes.

Step #5: Flush Privileges and Exit

After changing the password, flush the privileges to update the changes and exit the MySQL shell:

mysql> FLUSH PRIVILEGES;
mysql> exit

Step #6: Stop MySQL Safe Mode

Stop the MySQL safe mode instance:

ubuntu@Rushi-InfoTech:~$ sudo killall -u mysql

If you see any MySQL output with ended message hit ‘ENTER’ to continue.

Step #7: Start MySQL Service

Start the MySQL service:

ubuntu@Rushi-InfoTech:~$ sudo systemctl start mysql

Step #8: Verify New Password

To confirm that the root password has been successfully reset, try logging in with the new password:

ubuntu@Rushi-InfoTech:~$ mysql -u root -p

Enter the new password when prompted, and you should have access to the MySQL server.

Conclusion:

In this guide, we’ve demonstrated how to reset the MySQL 8 root password on Ubuntu 20.04. Losing access to your database can be a challenging situation, but by following these steps, you can regain control and secure your MySQL installation with a new root password.

Remember to keep your new password secure, as it grants full access to your MySQL database server. This process ensures that you can maintain control and security over your MySQL database, even in situations where the root password is lost or forgotten.

For Reference:

To know about MySQL pls visit official Website.

Any queries pls contact us
https://rushiinfotech.in/contact/

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *