In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to reset the root user's password in the MySQL database". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to reset the root user's password in the MySQL database.
On the Windows platform, this step is:
Log in to the system as a system administrator.
If the MySQL server is running, stop it. For a server running as a Windows service, go to the service manager:
Start menu-> Control Panel-> Administrative tools-> Services
Then find the MySQL server in the list and stop it.
If the server is not running as a service, you may need to use Task Manager to force it to stop.
Create 1 article article and place the following command on a single line:
SETPASSWORDFOR'root'@'localhost'=PASSWORD ('MyNewPassword')
Save the file with any name. In this case, the file is C:\ mysql-init.txt.
Open a console window and enter the DOS command prompt:
Start menu-> run-> cmd
Suppose you have installed MySQL to C:\ mysql. If you installed MySQL to another location, please adjust the following command accordingly.
From the DOS command prompt, execute the command:
C:\ > C:\ mysql\ bin\ mysqld-nt--init-file=C:\ mysql-init.txt
When the server starts, execute the contents of the file named by the "--init-file" option, and change the root password. When the server starts successfully, you should delete C:\ mysql-init.txt.
If you installed MySQL using the MySQL installation wizard, you may need to specify the "--defaults-file" option:
The following is the referenced content:
C:\ > C:\ ProgramFiles\ MySQL\ MySQLServer5.1\ bin\ mysqld-nt.exe
-defaults-file= "C:\ ProgramFiles\ MySQL\ MySQLServer5.1\ my.ini"
-- init-file=C:\ mysql-init.txt
Using the Service Manager, you can find the appropriate "--defaults-file" setting:
Start menu-> Control Panel-> Administrative tools-> Services
Find the MySQL service in the list, right-click, and select the Properties option. The "--defaults-file" setting is included in the Path (path) of the executable field.
Stop the MySQL server and restart it in normal mode. If you run the server as a service, you should start it from the Windows services window. If you start the server manually, you can use commands as you would normally do.
Should be able to connect with the new password.
In a Unix environment, the steps to reset the root password are as follows:
Log in to the system as Unix root, or as the same as running the mysqld server.
Locate the .pid file that contains the server process ID. The exact location and name of the file depends on your distribution, hostname, and configuration. The common locations are / var/lib/mysql/, / var/run/mysqld/, and / usr/local/mysql/data/. In general, the file name has a .pid extension and starts with the mysqld or the hostname of the system.
Shell > kill`cat / mysql-data-directory/host_ name.pid`
Note that the cat command uses the symbol "`" instead of "'": this causes the output of cat to be substituted into the kill command.
Create the article and place the following command on line 1 in the file:
SETPASSWORDFOR'root'@'localhost'=PASSWORD ('MyNewPassword')
Save the file with any name. For this example, the file is ~ / mysql-init.
Restart the MySQL server with the special "--init-file=~/mysql-init" option:
Shell > mysqld_safe--init-file=~/mysql-init&
The contents of the file init-file are executed when the server starts, changing the root password. After the server starts successfully, the ~ / mysql-init should be deleted.
Should be able to connect with the new password.
Optionally, on any platform, you can use the mysql client to set a new password (but this method is not secure enough):
Stop mysqld and restart it with the "--skip-grant-tables--user=root" option (Windows users can omit the-- user=root section).
Connect to the mysqld server using the following command:
Shell > mysql-uroot
Issue the following statement on the mysql client:
The following is the referenced content:
Mysql > UPDATEmysql.userSETPassword=PASSWORD ('newpwd')
-> WHEREUser='root'
Mysql > FLUSHPRIVILEGES
Replace "newpwd" with the actual root password you intend to use.
At this point, I believe you have a deeper understanding of "how to reset the root user's password in the MySQL database". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.