Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use replace into to create a root privileged user after skipping authorization table login

2025-04-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Cause:

Just set up the mysql database, do basic optimization, accidentally delete all users, and quit. We have no choice but to skip the authorization table and log in and create a new root user.

The process is as follows:

First, stop mysql and skip authorization login

[root@explnk-zabbix zabbix-2.2.9] # / etc/init.d/mysqld stop

Shutting down MySQL... SUCCESS!

[root@explnk-zabbix zabbix-2.2.9] # mysqld_safe-- skip-grant-table &

[1] 30178

[root@explnk-zabbix zabbix-2.2.9] # 160418 10:49:54 mysqld_safe Logging to'/ application/mysql/data/explnk-zabbix.err'.

160418 10:49:54 mysqld_safe Starting mysqld daemon with databases from / application/mysql/data

[root@explnk-zabbix zabbix-2.2.9] # mysql

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

Your MySQL connection id is 1

Server version: 5.5.32 MySQL Community Server (GPL)

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

2. Create users with root permissions

2.1 examples of errors:

A pit is encountered at the beginning. The user created with insert into does not have any permissions and cannot operate after logging in. The statement is as follows:

INSERT INTO user (Host,User,Password) VALUES ('localhost','root',PASSWORD (' biscuit'))

* 2. Row * *

Host: localhost

User: root

Password: * 7495041D24E489A0096DCFA036B166446FDDD992

Select_priv: N

Insert_priv: N

Update_priv: N

Delete_priv: N

Create_priv: N

Drop_priv: N

Reload_priv: N

Shutdown_priv: N

Process_priv: N

File_priv: N

Grant_priv: N

References_priv: N

Index_priv: N

Alter_priv: N

Show_db_priv: N

Super_priv: N

Create_tmp_table_priv: N

Lock_tables_priv: N

Execute_priv: N

Repl_slave_priv: N

Repl_client_priv: N

Create_view_priv: N

Show_view_priv: N

Create_routine_priv: N

Alter_routine_priv: N

Create_user_priv: N

Event_priv: N

Trigger_priv: N

Create_tablespace_priv: N

Ssl_type:

Ssl_cipher:

X509_issuer:

X509_subject:

Max_questions: 0

Max_updates: 0

Max_connections: 0

Max_user_connections: 0

Plugin:

Authentication_string: NULL

2.2 correct method 1:

Mysql > use mysql

Database changed

Mysql > insert into 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 Values ('Event_priv, Trigger_priv,Create_tablespace_priv,User,Password) values (' Yaoyumi, Yaoyun, Yaoyun, Yaoyun 'Yhere 's a lot of money,'he said.

Query OK, 1 row affected, 3 warnings (0.06 sec)

Mysql > update user set password=PASSWORD ('explink') where user='gl'

Query OK, 1 row affected (0.08 sec)

Rows matched: 1 Changed: 1 Warnings: 0

2.3 correct method 2:

You cannot use grant to establish a user after skipping authorization form login. The error is as follows:

Mysql > grant all privileges on *. * to liang@'localhost' identified by '123456' with grant option

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

Solution:

Just refresh the user permissions.

Mysql > flush privileges

Query OK, 0 rows affected (0.00 sec)

Mysql > grant all privileges on *. * to liang@'localhost' identified by '123456' with grant option

Query OK, 0 rows affected (0.00 sec)

Log out and restart mysql

[root@explnk-zabbix zabbix-2.2.9] # / etc/init.d/mysqld stop

[root@explnk-zabbix zabbix-2.2.9] # / etc/init.d/mysqld start

4. Log in to mysql to view permissions

[root@explnk-zabbix zabbix-2.2.9] # mysql-ugl-p

Enter password:

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

Your MySQL connection id is 1

Server version: 5.5.32 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, 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 > select * from mysql.user\ G

* 3. Row * *

Host:

User: gl

Password: * 5F70B50879BD3B98CB5A945D3A6A7C92F41B8AE8

Select_priv: Y

Insert_priv: Y

Update_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

Alter_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

Event_priv: Y

Trigger_priv: Y

Create_tablespace_priv: Y

Ssl_type:

Ssl_cipher:

X509_issuer:

X509_subject:

Max_questions: 0

Max_updates: 0

Max_connections: 0

Max_user_connections: 0

Plugin:

Authentication_string: NULL

3 rows in set (0.00 sec)

VI. Perfect

Refer to blog: http://my.oschina.net/leejun2005/blog/76140

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report