For new users

Source: Internet
Author: User

We all know that the problem of changing the user password in MySQL has always been a nightmare for new users. In this case, new users often encounter errors, and eventually cannot access the MySQL database, so here are some examples to illustrate.

1. The original password is 123456.

 
 
  1. C:\>type MySQL5.bat  
  2. @echo off  
  3. MySQL -uroot -p123456 -P3306 

The correct format for modifying the MySQL user password is:

We use

User: root can be changed to another one)

Password: woshiduide

To demonstrate the new password.

 
 
  1. C:\>MySQLadmin -uroot -p password woshiduide  
  2. Enter password: ****** 

The modification is successful. Note that many spaces behind the PASSWORD keyword are modified as follows:

 
 
  1. C:\>MySQLadmin -uroot -p password ‘woshiduide’  
  2. Enter password: ******  
  3. C:\>MySQLadmin -uroot -p password ‘woshiduide’  
  4. Enter password: *********  
  5. Warning: single quotes were not trimmed from the password by your command  
  6. line client, as you might have expected.  
  7.  

In this case, the real password is 'woshiduide'

 
 
  1. C:\>MySQL -uroot -p’woshiduide’  
  2. Welcome to the MySQL monitor. Commands end with ; or \g.  
  3. Your MySQL connection id is 18  
  4. Server version: 5.1.17-beta-community-nt-debug MySQL Community Server (GPL)  
  5. Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.  
  6. MySQL> 
  7.  

In actual operations on changing the password of a MySQL user, This is often the case for new users:

 
 
  1. C:\>MySQL -uroot -pwoshiduide  
  2. ERROR 1045 (28000): Access denied for user ‘root’@'localhost’ (using password: Y  
  3. ES) 

So it was very depressing. BAIDU and GOOGLE searched a lot.

Change the password.

 
 
  1. C:\>MySQLadmin -uroot -p’woshiduide’ password 123456 

2. You can directly access MySQL and change the password.

 
 
  1. MySQL> use MySQL  
  2. Database changed  
  3. MySQL> update user set PASSWORDPASSWORD = PASSWORD(‘woshiduide’) where USER=’root’ and H  
  4. OST=’localhost’;  
  5. Query OK, 1 row affected (0.05 sec)  
  6. Rows matched: 1 Changed: 1 Warnings: 0  
  7. MySQL> flush privileges;  
  8. MySQL> exit  
  9. Bye  
  10. C:\>MySQL -uroot -pwoshiduide  
  11. Welcome to the MySQL monitor. Commands end with ; or \g.  
  12. Your MySQL connection id is 23  
  13. Server version: 5.1.17-beta-community-nt-debug MySQL Community Server (GPL)  
  14. Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.  
  15. MySQL> 
  16. Query OK, 0 rows affected (0.02 sec)  

3. Use the set password command to modify the PASSWORD:

 
 
  1. C:\>MySQL5.bat  
  2. Enter password: ******  
  3. Welcome to the MySQL monitor. Commands end with ; or \g.  
  4. Your MySQL connection id is 8  
  5. Server version: 5.1.17-beta-community-nt-debug-log MySQL Community Server (GPL)  
  6. Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.  
  7. MySQL> set password for root@’localhost’ = password(‘woshiduide’);  
  8. Query OK, 0 rows affected (0.02 sec)  
  9. MySQL> flush privileges;  
  10. Query OK, 0 rows affected (0.09 sec)  
  11. MySQL> exit  
  12. Bye  

4. GRANT is acceptable, but it is not described here. Because of permission issues.

The above content is an introduction to changing the user password of MySQL. I hope you will gain some benefits.
 

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.