MySQL User table root Delete solution by mistake

Source: Internet
Author: User

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

Related Article

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.