莫辂技术
今天是:
我需要三件东西:爱情友谊和图书。然而这三者之间何其相通!炽热的爱情可以充实图书的内容,图书又是人们最忠实的朋友。
User Image MYSQL 无root用户或root用户被删除解决方法 2018-10-27

注:先改变文件my.ini  mysqld下加入skip-grant-tables

Microsoft Windows [版本 10.0.14393]

(c) 2016 Microsoft Corporation。保留所有权利。

 

C:\WINDOWS\system32>cd C:\Program Files\MySQL\MySQL Server 5.7\bin

 

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p

Enter password: ******

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

 

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.7.12-log MySQL Community Server (GPL)

 

Copyright (c) 2000, 2016, 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

Database changed

mysql> UPDATE user SET authentication_string=PASSWORD('111111') where USER='root';

Query OK, 0 rows affected, 1 warning (0.00 sec)

Rows matched: 0  Changed: 0  Warnings: 1

 

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

mysql> select * from user;

+-----------+-----------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-------------------------------------------+------------------+-----------------------+-------------------+----------------+

| Host      | User      | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | Create_tablespace_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections | plugin                | authentication_string                     | password_expired | password_last_changed | password_lifetime | account_locked |

+-----------+-----------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-------------------------------------------+------------------+-----------------------+-------------------+----------------+

| localhost | mysql.sys | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          | N            | N          | N                     | N                | N            | N               | N                | N                | N              | N                   | N                  | N                | N          | N            | N                      |          |            |             |              |             0 |           0 |               0 |                    0 | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | N                | 2016-04-20 00:15:15   |              NULL | Y              |

+-----------+-----------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-------------------------------------------+------------------+-----------------------+-------------------+----------------+

1 row in set (0.00 sec)

 

mysql> quit;

Bye

 

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p

Enter password: ******

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

 

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root

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

 

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.7.12-log MySQL Community Server (GPL)

 

Copyright (c) 2000, 2016, 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;

Database changed

mysql> update user set password=PASSWORD("111111") where user="root";

ERROR 1054 (42S22): Unknown column 'password' in 'field list'

mysql> update user set authentication_string=PASSWORD("111111") where user="root";

Query OK, 0 rows affected, 1 warning (0.00 sec)

Rows matched: 0  Changed: 0  Warnings: 1

 

mysql> select count(*) from user;

+----------+

| count(*) |

+----------+

|        1 |

+----------+

1 row in set (0.00 sec)

 

mysql> select * from user where user="root";

Empty set (0.00 sec)

 

mysql> select user from user ;

+-----------+

| user      |

+-----------+

| mysql.sys |

+-----------+

1 row in set (0.00 sec)

 

mysql> insert into user set user='root',ssl_cipher='',x509_issuer='',x509_subject='';

Query OK, 1 row affected (0.00 sec)

 

mysql> update user set Host='localhost',select_priv='y', insert_priv='y',update_priv='y',Alter_priv='y',delete_priv='y',create_priv='y',drop_priv='y',reload_priv='y',shutdown_priv='y',Process_priv='y',file_priv='y',grant_priv='y',References_priv='y',index_priv='y',show_db_priv='y',super_priv='y',create_tmp_table_priv='y',Lock_tables_priv='y',execute_priv='y',repl_slave_priv='y',repl_client_priv='y',create_view_priv='y',show_view_priv='y',create_routine_priv='y',alter_routine_priv='y',create_user_priv='y' where user='root';

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0

 

mysql> quit;

Bye

 

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.7.12-log MySQL Community Server (GPL)

 

Copyright (c) 2000, 2016, 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> update user set authtication_string=PASSWORD("111111") where user="root";

ERROR 1046 (3D000): No database selected

mysql> user mysql;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'user mysql' at line 1

mysql> use mysql;

Database changed

mysql> update user set authtication_string=PASSWORD("111111") where user="root";

ERROR 1054 (42S22): Unknown column 'authtication_string' in 'field list'

mysql> update user set authentication_string=PASSWORD("111111") where user="root";

Query OK, 1 row affected, 1 warning (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 1

 

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

 

mysql> quit;

Bye

 

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p

Enter password: ******

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.7.12-log MySQL Community Server (GPL)

 

Copyright (c) 2000, 2016, 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>

45 likes - 2 comments

我的

类型标签

外部链接

网站访问总量