MySQL User table root Delete solution by mistake
1, first to root user login system;
2, close the MySQL service:/etc/init.d/mysql stop;
3. Privilege start Mysql:/usr/local/mysql/bin/mysqld_safe--user=mysql--skip-grant-tables--skip-networking & (Note: Parameter--skip-grant-tables is skip authorization table)
4. Login to skip the authorization table database: #mysql-uroot-h localhost
5. View User table:mysql> Select Host,user,password from Mysql.user;
6. Insert the root table:mysql> insert into Mysql.user (host,user,password,ssl_cipher,x509_issuer,x509_subject,authentication_ String) VALUES (' localhost ', ' root ', password (' 123456 '), ', ', ', ', ');
7. Add root to all permissions in the root table:
1) Query Permissions
SELECT * from Mysql.user where user= ' root ' and host= ' localhost ' \g
2) Update mysql.user set select_priv= ' y ', insert_priv= ' y ', update_priv= ' y ', delete_priv= ' y ', create_priv= ' y ', drop_priv = ' y ', reload_priv= ' y ', sh= ' 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 ' where user= ' root ' and host= ' localhost ';
3) Verify Permissions
SELECT * from Mysql.user where user= ' root ' and host= ' localhost ' \g
8, Turn & Refresh Permissions
Commit
Flush Prvilileges;
9. Restart MySQL
[Email protected] ~]#/etc/init.d/mysqld restart
10. Login Verification
Mysql-u root-p
Mysql> Show grants;
This article is from "David's operation and maintenance of private cuisine" blog, please be sure to keep this source http://dawei2015.blog.51cto.com/140637/1714964
MySQL User table root Delete solution by mistake