Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

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

Posted on Jul 25 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 ServiceThe 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:Step 2: Create a Temporary Configuration FileNext, 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:Step 3: Add Configuration to the FileIn the nano editor, add the following lines to the reset-mysql-password.cnf file.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 ModeWith the temporary configuration file in place, start the MySQL service in safe mode:Step 5: Connect to MySQL Without PasswordNow, we can connect to the MySQL server without entering a password. Open a new terminal window and run the following command:Step 6: Set a New Password for Root UserOnce you are connected to the MySQL prompt, it's time to set a new password for the root user. Execute the following SQL commands: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 passwordYou can fix this like below, if you want to use weak password(Not recommended)Now again run the password update sql:Step 7: Exit MySQL and Remove the Configuration FileAfter setting the new password, exit the MySQL prompt:Remove the temporary configuration file:Step 8: Restart MySQL ServiceFinally, restart the MySQL service to apply the changes: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 .Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well Confirm For further actions, you may consider blocking this person and/or reporting abuse angDecoder - Jul 9 Sadeedpv - Jul 18 Justin Verthein - Jul 18 Michael Z - Jun 25 Once suspended, asifzcpe will not be able to comment or publish posts until their suspension is removed. Once unsuspended, asifzcpe will be able to comment and publish posts again. Once unpublished, all posts by asifzcpe will become hidden and only accessible to themselves. If asifzcpe is not suspended, they can still re-publish their posts from their dashboard. Note: Once unpublished, this post will become invisible to the public and only accessible to Md. Asif Rahman. They can still re-publish the post if they are not suspended. Thanks for keeping DEV Community safe. Here is what you can do to flag asifzcpe: asifzcpe consistently posts content that violates DEV Community's code of conduct because it is harassing, offensive or spammy. Unflagging asifzcpe will restore default visibility to their posts. DEV Community — A constructive and inclusive social network for software developers. With you every step of your journey. Built on Forem — the open source software that powers DEV and other inclusive communities.Made with love and Ruby on Rails. DEV Community © 2016 - 2023. We're a place where coders share, stay up-to-date and grow their careers.



This post first appeared on VedVyas Articles, please read the originial post: here

Share the post

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

×

Subscribe to Vedvyas Articles

Get updates delivered right to your inbox!

Thank you for your subscription

×