Today, on the basis of yesterday, it went wrong.

Source: Internet
Author: User

There was a problem with booting into MySQL this morning.

# Mysql-uroot-penter Password:error 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using password:yes) # MYSQ lmysql> use MySQL #不能用mysqlERROR 1044 (42000): Access denied for user ' root ' @ '% ' to database ' MySQL ' mysql> us       E test #能用testDatabase changedmysql> SELECT user,host,password from user; ERROR 1044 (42000): Access denied for user ' root ' @ '% ' to database ' MySQL '

Okay, quit, turn off MySQL, use safe mode

# service mysqld stop# mysqld_safe --user=mysql --skip-grant-tables -- skip-networking &# mysql -u root mysqlmysql> use mysqldatabase  changedmysql> select user,host,password from user;+-------------+----------------+----- --------------------------------------+| user        | host            | password                                    |+-------------+----------------+----- --------------------------------------+| root        | %               |                                             | |  root        | www.crwolf.com | * df216f57f1f2066124e1aa5491d995c3cb57e4c2 |+-------------+----------------+------------------------------- ------------+

So where did my previous user go?

Host: 127.0.0.1, User: Root, password is empty
Host::: 1, User: Root, password is empty
Host: localhost, user is empty, password is empty

How did these three automatically delete me?

Just like the time http24 called MySQL, my root user, the welcome password is automatically gone.


Alas, delete anonymous users. How can this MySQL be so fickle?

mysql> drop user  ' root ' @ '% ';     #错误又来了ERROR  1290  (HY000):  the mysql server is running with the --skip-grant-tables option  so it cannot execute this statementmysql> flush privileges; query ok, 0 rows affected  (0.01 sec) mysql> drop user  ' root ' @ '% ';         #好了Query  OK, 0 rows affected  (0.00  SEC)     mysql> select user,host,password from user;+--------- ----+----------------+-------------------------------------------+| user         | host           | password                                     |+-------------+----------------+---------- ---------------------------------+| root        |  www.crwolf.com | *df216f57f1f2066124e1aa5491d995c3cb57e4c2 |+-------------+----------------+--- ----------------------------------------+mysql> \qbye

The problem is not solved.

# service Mysqld startstarting MySQL [ok]# mysql-uroot-p Enter passwo Rd:error 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes)

One more Safe mode.

# service mysqld stop# mysqld_safe --user=mysql --skip-grant-tables -- Skip-networking &# mysql -u root mysqlmysql> delete from user  where user= "; query ok, 0 rows affected  (0.00 sec) mysql> flush privileges; query ok, 0 rows affected  (0.01 sec) mysql> \qbye# service  mysqld startstarting mysql                                               [Determine]# mysql  -uroot -pEnter password: ERROR 1045  (28000):  access denied for  user  ' root ' @ ' localhost '   (using password: yes) # mysqladmin -uroot -p  password  ' Welcome '          #改密码都不能改, to cry enter password: mysqladmin:  connect to server at  ' localhost '  failederror:  ' access denied for  user  ' root ' @ ' localhost '   (using password: yes) '


Solved, and found a master to help
Still going into safe mode?

# service Mysqld stop# mysqld_safe--user=mysql--skip-grant-table--skip-networking &

This way, we will not move, and then open a new terminal.

# mysql-uroot-pmysqlmysql> use MySQL Database changed

Not always shown when logged in MySQL error

ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes)

Now that you show it, create a root user, host localhost, password welcome

Mysql> insert   user (Host,user,password)  VALUES  (' localhost ', ' root ', password ( ' Welcome ')); query ok, 1 row affected, 3 warnings  (0.00 sec)               #我这创建成功了mysql > select user,host,password  from user;        +-------------+----------------+--------- ----------------------------------+| user        | host            | password                                    |+-------------+----------------+----- --------------------------------------+| root        |   | *81f5e21e35407d884a6cd4a731aebfb6af209e1b | |  root        | localhost       | *df216f57f1f2066124e1aa5491d995c3cb57e4c2 |+-------------+----------------+----------------------- --------------------+

If this is an error,

ERROR 1290 (HY000): The MySQL server is running with the--skip-grant-tables option so it cannot execute this statement

Execute the flush privileges and then create

mysql> flush Privileges;

And then authorize, be sure to authorize

Mysql> GRANT All privileges on * * to ' root ' @ ' localhost '; Query OK, 0 rows Affected (0.00 sec) mysql> flush privileges;

You can exit the
Back to the end of the terminal

# service mysqld start# mysql -uroot - pwelcomewelcome to the mysql monitor.  commands end with ;  or \g.your mysql connection id is 1server version: 5.5.36-log  source distributioncopyright  (c)  2000, 2014, 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> 

Problem solved, I decided later in MySQL to execute any command after, all execute the flush privileges This command, lest error. Anyway, each time you execute the command and press the UP ARROW, the command comes out, does not delay the time, and can avoid errors.

This article is from the "three elder brother" blog, please be sure to keep this source http://523958392.blog.51cto.com/9871195/1630639

Today, on the basis of yesterday, it went wrong.

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.