Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 6895

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 60k
Author
Asked: November 27, 20242024-11-27T10:46:08+00:00 2024-11-27T10:46:08+00:00

Resetting MySQL Root Password in Ubuntu: A Step-by-Step Guide

  • 60k

Introduction:
Losing or forgetting the MySQL root password can be a stressful situation, but don't worry; there's a way to regain access to your MySQL database in Ubuntu. In this article, I will walk you through a step-by-step guide on how to reset the MySQL root password on your Ubuntu system. We will use a method that involves stopping the MySQL service, creating a temporary configuration file, and setting a new password for the root user.

Step 1: Stop the MySQL Service
The first step is to stop the MySQL service to ensure we can safely proceed with the password reset process. Open your terminal and run the following command:

sudo service mysql stop 
Enter fullscreen mode Exit fullscreen mode

Step 2: Create a Temporary Configuration File
Next, we'll create a temporary configuration file to start the MySQL service without password authentication. This will allow us to reset the root password. Run the following command to create the file:

sudo nano /etc/mysql/mysql.conf.d/reset-mysql-password.cnf 
Enter fullscreen mode Exit fullscreen mode

Step 3: Add Configuration to the File
In the nano editor, add the following lines to the reset-mysql-password.cnf file.

[mysqld] skip-grant-tables 
Enter fullscreen mode Exit fullscreen mode

To save the changes and exit the editor, press CTRL + X, then type Y, and finally, press Enter.

Step 4: Start MySQL Service in Safe Mode
With the temporary configuration file in place, start the MySQL service in safe mode:

sudo mysqld_safe --skip-grant-tables & 
Enter fullscreen mode Exit fullscreen mode

Step 5: Connect to MySQL Without Password
Now, we can connect to the MySQL server without entering a password. Open a new terminal window and run the following command:

mysql -u root  
Enter fullscreen mode Exit fullscreen mode

Step 6: Set a New Password for Root User
Once you are connected to the MySQL prompt, it's time to set a new password for the root user. Execute the following SQL commands:

FLUSH PRIVILEGES; ALTER USER 'root'@'localhost' IDENTIFIED BY 'YOUR_NEW_PASSWORD'; 
Enter fullscreen mode Exit fullscreen mode

Replace 'YOUR_NEW_PASSWORD' with your desired password. The FLUSH PRIVILEGES; command ensures that the changes take effect immediately.

If you get the following error while using weak password

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 
Enter fullscreen mode Exit fullscreen mode

You can fix this like below, if you want to use weak password(Not recommended)

SHOW VARIABLES LIKE 'validate_password%'; SET GLOBAL validate_password.policy=LOW; 
Enter fullscreen mode Exit fullscreen mode

Now again run the password update sql:

Step 7: Exit MySQL and Remove the Configuration File
After setting the new password, exit the MySQL prompt:

exit; 
Enter fullscreen mode Exit fullscreen mode

Remove the temporary configuration file:

sudo rm /etc/mysql/mysql.conf.d/reset-mysql-password.cnf 
Enter fullscreen mode Exit fullscreen mode

Step 8: Restart MySQL Service
Finally, restart the MySQL service to apply the changes:

sudo service mysql restart 
Enter fullscreen mode Exit fullscreen mode

Congratulations! You have successfully reset the MySQL root password on your Ubuntu system. Now you can access your MySQL database using the new password you set. Always make sure to keep your MySQL root password secure .

mysqlmysqlpasswordresetubuntuwebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 1k
  • Popular
  • Answers
  • Author

    How to ensure that all the routes on my Symfony ...

    • 0 Answers
  • Author

    Insights into Forms in Flask

    • 0 Answers
  • Author

    Kick Start Your Next Project With Holo Theme

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.