Modify the mysql logon Password

Source: Internet
Author: User
When the end of the machine, can log on to linux but cannot log on to mysql: mysql-urootERROR1045 (28000): Accessdeniedforuserroot @ localhost (usingpassword: NO) mysql-uroot-perror: Accessdeniedforuserroot @ localhost (usingpassword: YES) This

When you encounter a zombie machine, you can log on to linux but cannot log on to mysql: mysql-u root ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: NO) mysql-u root-p error: 'Access denied for user' root' @ 'localhost' (using password: YES) 'Here

You can log on to linux, but cannot log on to mysql:

Mysql-u root
ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: NO)

Mysql-u root-p

Error: 'Access denied for user' root' @ 'localhost' (using password: YES )'

If MySQL is running, killall-TERM mysqld is first killed.

Then start/usr/bin/mysqld_safe -- skip-grant-tables &

In this case, you can directly enter mysql to log on,

$ Mysql
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 1
Server version: 5.6.14 MySQL Community Server (GPL)


Copyright (c) 2000,201 3, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.


Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.


Mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-


Database changed
Mysql> update user set password = password ("root") where user = "root ";
Query OK, 4 rows affected (0.68 sec)
Rows matched: 4 Changed: 4 Warnings: 0


Mysql> flush privileges
->;
Query OK, 0 rows affected (0.00 sec)


Mysql>

Run killall-TERM mysqld again

Then start service mysql start

Then mysql-uroot-p can be logged on with root.

An error is reported after Logon:

Mysql> use mysql
ERROR 1820 (HY000): You must set password before executing this statement

, After you run set password = PASSWORD ('root ');

Mysql> set password = PASSWORD ('root ');
Query OK, 0 rows affected (0.19 sec)


Mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-


Database changed
Mysql>

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.