How to restore the root account after MySQL mistakenly deleted root

Source: Internet
Author: User

System:
CentOS Release 6.5 (Final)
Kernel:
2.6.32-431.el6.x86_64
MySQL version:
5.5.28-log Source Distribution
Operation Steps:
1. Stop the MySQL service
#service mysqld Stop
2. Enter MySQL in safe mode
#mysqld_safe--skip-grant-tables &
#mysql-u root-p \ The password is empty at this time
3. Rebuild Root
Mysql>use MySQL;
Mysql>insert into User (Host,user,password)
->values (' localhost ', ' root ', password (' password ')); \ The password here can be set later
4. Assigning permissions to the root user
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 ', event_priv= ' y ', trigger_priv= ' Y ', create_tablespace_priv= ' y ' where user= ' root ';

    1. Mysql> flush Privileges//Refresh
    2. Log out of MySQL, restart the MySQL service, and restore the root account to completion
      Note: When assigning permissions to the root user, the Event_priv, Trigger_priv, create_tablespace_priv Three permissions must be added, or even if the root user is restored, you cannot give all privileges permissions to other users.

How to restore the root account after MySQL mistakenly deleted root

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.