mysql--4 ways to modify the root password (for example, Windows) _mysql
Source: Internet
Author: User
Method 1: Using the Set password command First login to MySQL.
Format:mysql> set password for user name @localhost = password (' new password ');
Example:mysql> Set password for root@localhost = password (' 123 ');
Method 2: With Mysqladmin Format: Mysqladmin-u username-P Old password password new password
Example: mysqladmin-uroot-p123456 password 123
Method 3: Edit the user table directly with update First login to MySQL.
mysql> use MySQL;
mysql> Update user set Password=password (' 123 ') where user= ' root ' and host= ' localhost ';
mysql> flush Privileges;
Method 4: When you forget the root password, you can do this take windows as an example: 1. Close the running MySQL service.
2. Open the DOS window and go to the Mysql\bin directory.
3. Enter Mysqld--skip-grant-tables carriage return. --skip-grant-tables means to skip permission table authentication when starting the MySQL service.
4. Open a DOS window again (because the DOS window is already unable to move), go to the Mysql\bin directory.
5. Enter MySQL return, if successful, will appear MySQL prompt >.
6. Connection rights database: use MySQL;.
6. Change Password: Update user set Password=password ("123") where user= "root" (don't forget to add the semicolon).
7. Refresh permission (must step): Flush privileges;
8. Exit quit.
9. Logout the system, and then enter, using username root and just set the new password 123 login.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.