Mysql User table root deleted by mistake after recovery

Source: Internet
Author: User

MySQL User table root users mistakenly deleted after recovering the root user

Method/Step

1. Stop the MySQL service; Locate the My.ini in the MySQL installation directory, locate the following fragment in the My.ini [mysqld], and add another line to the code: Skip-grant-tables and save

2. Start the MySQL service and log in to MySQL (no username and password); Find user table join root user insert into Host,user,password VALUES (' localhost ', ' root ', Password (' 123456 '));

3, root user set permissions 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 ', create_user_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 '; commit;

4. Delete the line that My.ini just joined and restart the service

5, log in with the root user, ok!

Mysql User table root deleted by mistake after recovery

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.