In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
After installing the database, because you accidentally closed the installation window directly, or did not use root users to log on to the system for a long time, resulting in forgetting the root password, you need to reset the MySQL root password. Of course, the easiest way is to delete the data directory of the database, and then reinstall the database. But a lot of time we need to keep the data in the data directory, so we need to find out how to reset the root password.
We know that when you know the root password, you can use the "ALTER USER 'root'@'localhost' IDENTIFIED BY' new password;" directive to change the root user's password, as shown in the following figure:
Only need this line of instructions to complete the re-setting of the root password, without other operations, very simple.
But how do you reset it if you forget your root password? According to the description of the official document, there are two ways to change the password under the Windows system. Please refer to the link for the official document.
Option 1: execute the initialization file
Step 1: log in to the system using an account with administrative privileges
Step 2: stop the service of MySQL. No matter what method you use, you must stop it, as shown below:
Step 3: create a file mysql-init.txt with the password change instruction "ALTER USER 'root'@'localhost' IDENTIFIED BY' new password';", and then save the file, as shown in the figure:
Step 4: in the terminal interface, go to the bin directory of the MySQL installation:
Step 5: under the bin directory, execute mysqld, and specify the mysql-ini.txt you just created as the initialization file, and use the instruction "mysqld-defaults-file=" D:\ Programs\ MySQL\ MySQL-8.0.12-winx64\ my.ini "- init-file=" D:\ Programs\ MySQL\ mysql-ini.txt "", where-defaults-file specifies the configuration file and-init-file specifies the initialization file, as shown in the following figure:
After pressing the enter key, do not close the terminal. You need to open another terminal to confirm whether the password change is successful:
Obviously, the login is successful, the way to change the password is correct!
Of course, if you do shut down the terminal, you can use the "net start MySQL" instruction to start MySQL, and then verify it:
Step 6: delete the created mysql-ini.txt file, of course, it is OK not to delete it!
Option 2: reset the root password by skipping authentication at login
Step 1: first shut down the MySQL service, and then use the "- skip-grant-tables" configuration item to skip permission verification and restart the MySQL service:
The instruction used here is "mysqld-shared-memory-skip-grant-tables". If it is only "mysqld-skip-grant-tables", it will cause mysqld to fail to start, prompting "TCP/IP,-shared-memory, or-named-pipe should be configured on NT OS" error. After testing, only by adding "- shared-memory" can you start and access the database.
Step 2: open a terminal, log in to the database in a secret-free way, and run mysql directly:
/ p >
Step 3: first refresh the execution instruction "FLUSH PRIVILEGES;" and refresh the permissions:
Then execute the instruction "ALTER USER 'root'@'localhost' IDENTIFIED BY' new_psd_123';" to update the password, and "new_psd_123" is the new password set:
After the setting is completed, start the MySQL service normally and use the user name and password to verify whether the setting is successful!
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.