MySQL Modify user password

Source: Internet
Author: User

1) command-line mode

# mysqladmin-u root-p ' redhat12345 ' password ' zabbix12345 '-s/data/3306/mysql.sock change password redhat12345 to zabbix12345

2) SQL statement modification method

mysql> update mysql.user set password= ' 12345 '  where user= ' root '  and   host= ' localhost '; query ok, 1 row affected  (0.00 sec) rows matched: 1  changed:  1  Warnings: 0mysql> flush privileges; query ok, 0 rows affected  (0.00 sec) Mysql> select user,host, password from mysql.user;+------+------------+-------------------------------------------+|  user | host       | password                                    |+------+------------+---------------------- ---------------------+| root | localhost  | 12345                                       | |  root | C67-X64-A8 |                                             | |  root | 127.0.0.1  |                                             | |  root | ::1        |                                             | |       | localhost  |                                             | |       | C67-X64-A8 |                                             | |  wan  | %          | * 84bb5df4823da319bbf86c99624479a198e6eee9 | |  wan  | 10.10.10.% | *84bb5df4823da319bbf86c99624479a198e6eee9 | |  rep  | 10.10.10.% | *2698a63e7f5138951b60f853417adb4ce2a02d87 |+------+------------+----- --------------------------------------+9 rows in set  (0.00 sec) Description: We found the results shown above, Password is incredibly clear, it is clear that it is not possible to log into the database correctly: combine the password () function: Mysql> update mysql.user set password =password (redhat12345)  where user= ' root '  and  host= ' localhost '; error 1054  (42S22): unknown column  ' redhat12345 '  in  ' field list ' Error reason, Strings should be enclosed in quotation marks (either single or double quotes) Mysql> update mysql.user set password=password (' redhat12345 ')  where user= ' root '  and  host= ' localhost '; query ok, 1 row affected  (0.00 sec) rows matched: 1  changed:  1  Warnings: 0mysql> flush privileges; query ok, 0 rows affected  (0.00 sec) login to test:[[email protected]  Mysqlback]# mysql -uroot -predhat12345 -s /data/3306/mysql.sockwelcome to the mysql  Monitor.  commands end with ; or \g.your mysql connection id  is 27Server version: 5.5.32-log Source distributionCopyright  (c)  2000 ,  2013, oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or  Itsaffiliates. other names may be trademarks of their respectiveowners . type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement.mysql>


3) Use the SET command to resolve (not suitable for--skip-grant-tables mode change password)

Mysql> set Password=password ("redhat12345"); Query OK, 0 rows affected (0.01 sec) mysql> flush privileges; Query OK, 0 rows Affected (0.00 sec)

Attention:

A) When changing the password, you must specify the WHERE condition

b) Use the password () function to encrypt the change password


This article is from the "Frozen vs watermelon" blog, so be sure to keep this source http://molewan.blog.51cto.com/287340/1861052

MySQL Modify user password

Related Article

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.