Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to forcibly change the root password of MySQL

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to forcibly modify MySQL's root password". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and go deep into it slowly to study and learn "how to forcibly modify MySQL's root password" together!

Below we provide 6 different ways to change the MySQL root password and add MySQL users.

method one

Using phpmyadmin, which is the simplest, modify the MySQL database user table,

Don't forget to use the PASSWORD function.

methodology II

Use MySQLadmin, which is a special case of the previous declaration.

Double-click code Select All 1MySQLadmin -u root -p password mypasswd

Here is the code snippet:

After entering this command, you need to enter the original password of root, and then the password of root will be changed to mypasswd.

Change root to your username in the command and you can change your password.

Of course, if your MySQL admin does not connect to MySQL server, or you have no way to execute MySQL admin,

Then this method is ineffective.

And MySQLadmin can't clear the password.

The following methods are used at the MySQL prompt and must have MySQL root privileges:

method three

Here is the code snippet:

MySQL> INSERT INTO MySQL.user (Host,User,Password) VALUES ('%','jeffrey',PASSWORD ('biscuit')); MySQL> FLUSH PRIVILEGES

Specifically, it's adding a user with the username jeffrey and password biscuit.

There is an example of this in MySQL Chinese Reference Manual, so I wrote it out.

Note that PASSWORD is used, followed by FLUSH PRIVILEGES.

method four

Same as method 3, except using the REPLACE statement

MySQL> REPLACE INTO MySQL.user (Host,User,Password) VALUES ('%','jeffrey',PASSWORD ('biscuit')); MySQL> FLUSH PRIVILEGES

Here is the code snippet:

method five

Using SET PASSWORD statements,

Here is the code snippet:

MySQL> SET PASSWORD FOR jeffrey@"%" = PASSWORD ('biscuit ');

The PASSWORD() function must also be used,

However, FLUSH PRIVILEGES is not required.

method a

Using GRANT... IDENTIFIED BY statement

Here is the code snippet:

Double-click the code Select All 1MySQL> GRANT USAGE ON *.* TO jeffrey@"%" IDENTIFIED BY 'biscuit';

The PASSWORD() function is unnecessary here, and there is no need to use FLUSH PRIVILEGES.

Note: PASSWORD() [not] enforces password encryption in the same way as Unix password encryption.

MySQL Forgot Password Solution

If MySQL is running, kill it first: killall -$TERM MySQL.

Start MySQL: bin/safe_MySQL--skip-grant-tables &

You can enter MySQL without a password.

And then:

Here is the code snippet:

Double-click code Select All 1 2 3 4 5use MySQL update user set password=password("new_pass") where user="root"; flush privileges;

Kill MySQL again and start MySQL the normal way.

Thank you for reading, the above is the content of "how to force change MySQL root password", after the study of this article, I believe that everyone has a deeper understanding of how to force change MySQL root password, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

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: 250

*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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report