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

What are the methods of modifying MySQL password

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly introduces "what are the methods of modifying the MySQL password". In the daily operation, I believe that many people have doubts about the modification method of the MySQL password. The editor consulted all kinds of materials and sorted out the simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "what are the methods of modifying the MySQL password?" Next, please follow the editor to study!

What are the methods of modifying MySQL password

Method 1:

1. Edit the configuration file of MySQL (the best combination with PHP):

In windows environment:% MySQL (best combination with PHP) _ installdir%my.ini / / generally there is a configuration file for my.ini, MySQL (best combination with PHP) under the installation directory of MySQL (best combination with PHP).

In linux environment: / etc/my.cnf

Add the following line to the [MySQL (best combination with PHP) d] configuration section:

Skip-grant-tables

Save to exit editing.

2. Then restart the MySQL (the best combination with PHP) service

In a windows environment:

NetstopMySQL (the best combination with PHP)

NetstartMySQL (the best combination with PHP)

In a linux environment:

/ etc/init.d/MySQL (the best combination with PHP) drestart

3. Set a new ROOT password

Then execute it under the command line:

MySQL (best combination with PHP)-uroot-pMySQL (best combination with PHP)

Enter directly without a password to enter the database tutorial.

Now let's execute the following statement to update the root password to 7758521:

Updateusersetpassword=PASSWORD ("7758521") whereuser='root'

Quit quits MySQL (the best combination with PHP).

4. Restore the configuration file and restart the service

Then modify the MySQL (the best combination with PHP) configuration file to delete the line you just added.

Restart the MySQL (the best combination with PHP) service again, and the password has been changed.

Method 2:

Mysql > InsertINTOmysql.user (Host,User,Password) VALUES ('%', 'jeffrey',PASSWORD (' biscuit')); mysql > FLUSHPRIVILEGES

To be exact, this is adding a user with the user name jeffrey and the password biscuit. There is this example in the mysql Chinese reference Manual, so I wrote it out.

Note that you use the PASSWORD function, and then you use FLUSHPRIVILEGES.

Method 3:

Using mysqladmin, this is a special case of the previous declaration.

Mysqladmin-uroot-ppasswordmypasswd

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 the root in the command to your user name, and you can change your own password.

Of course, if your mysqladmin can't connect to mysqlserver, or if you can't execute mysqladmin, then this method doesn't work, and mysqladmin can't clear the password.

At this point, the study of "what are the ways to modify the MySQL password" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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.

Share To

Database

Wechat

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

12
Report