MySQL is undoubtedly an incredible software used to manage the data in a database in a well organized and secured way. In this blog, we are going to discuss the easiest way for How to change MySQL root password for making your data safer than ever.
To connect as the root user, there is no requirement of password if you have never assigned a password.
It is definitely unsecured as anyone can easily penetrate your account security to get data access.
So, it’s better you should keep the root password on MySQL for data privacy and prevention.
What is the Default password for MySQL root?
There is no password for root as per the default norms in MySQL program.
The username is selected as root but there is no password set for the same.
There is no doubt that having no password is unsecured for data safety.
However, in case you have assigned a password previously but have forgotten now, then there is an easy for retrieving back your password.
How do I find my MySQL root password?
As we already mentioned, the root password is not set by default in any system.
You have to create it by yourself to better protect the saved data from the attacks of hackers and all.
There is a way to change it if you don’t remember it any longer because of uncertain reasons.
We will mention the steps for how to change MySQL root password process further in this blog to make it easier for you guys to safeguard your account.
How do I change the root password in MySQL in Windows?
If you want to change or reset the root password in MySQL, then follow this easy guide.
We are going to provide a simple step by step tutorial for the same purpose in this blog.
Moreover, we will describe all the required steps in 3 different phases with proper guidelines.
So, just follow each of them carefully and with accuracy.
1) Here are the steps for Phase 1:
- First of all, you are required to stop MySQL services and programs.
- For this, press Windows+R keys simultaneously to open run command.
- Type “services.msc” in the search option.
- Now, click on the “OK” option and a new window with a list of all services will appear.
- Slowly scroll down and search for the MySQL service.
- Right-click on it and click on the “Stop” icon to stop the MySQL services immediately.
2) Now, we will mention the steps for Phase 2 below:
- Open the root directory location on your PC. Generally, its the C drive or D drive which is considered as root directory in the majority of the systems.
- Create a new text file there and follow the next step.
- Just copy and paste this mentioned line into the document:
ALTER USER ‘root‘@’localhost‘ IDENTIFIED BY ‘NewPassword‘;
Here, in place of NewPassword, you can enter the password of your own choice.
- Put the name of that file as “C:\mysql-init.txt” and save the changes using the save option and close the window afterward.
- Use the run option to open the Command prompt Windows by typing “cmd”.
3) Steps for the Phase 3:
- Now, we have to navigate to the location where the MySQL bin file is located.
- Check for the “Program files” folder in the Local Drive C of your PC or maybe in some other drive depending on different systems.
- Under the program files folder, you will see the MySQL folder.
- Open that folder followed by opening MySQL server and lastly, the bin file.
- Now, just copy the location path from the top and open back the Command prompt window.
- Type cd and in double-quotes, mention the path you have copied and press Enter key.
4) Steps for the Phase 4 process:
Keep in mind that this phase is an important one for the process of how to change MySQL root password. So, it’s better you should read it properly and then execute it.
- Now moving further with it, we have to locate my.ini file in PC which is generally located in the Program Data folder of C Drive.
- Again navigate to C drive and search for that folder.
- In case if it is not visible to you, then click on the “view” option available at the top menubar and choose the “Option” icon.
- Inside a new pop-up window, you will again find a “view option” where you can tick the “Show hidden files, folders and Drives”.
- Once you apply the settings, you will easily locate the Program data folder inside that drive.
- Open the MySQL folder present inside it where you have to open another folder named as MySQL server.
- You will find my.ini file inside that folder.
- Copy the path from the top and open the notepad application in your PC.
- Paste the copied path inside the double quotes of this command:
–defaults-file=”C:\\ProgramData\\MySQL\\MySQL Server 8.0\\my.ini”
- In case if you have named the text file that you have created in the first step with a different name, then you have to update it here.
- Please remember that you have to put the double slash in place of single slash everywhere in the above command.
- Now, just copy this whole command again from Notepad Window after arranging them in one single line and open Command prompt window again.
- Paste this command in the cmd window in front of the option where you left of previously by right-clicking there.
- Finally, press the Enter key and the process will get execute and terminate in a few moments.
- Open the services window again and run the MySQL service again from there.
You will see that you can log in as the root user in MySQL using your newly assigned password.
So, this is how the whole process of how to change MySQL root password ends.
How do I stop MySQL?
Stopping MySQL is pretty much simple.
All you have to do is just open the services windows in your PC and look out for the “MySQL” option there.
Stopping the MySQL service is indeed one of the important processes for how to change MySQL root password.
This is exactly what from where the whole process starts.
We know the process for how to change MySQL root password is a little tough and complex but this is the only way to change the root password.
We have put all our brilliant efforts in making it possible for you to understand this process and we really hope that we are succeeded in this.
Any further queries and suggestions are welcomed in the comments section available below.
Thanks a lot for the humble and polite reading.