MySQL database, delete root user after recovery

Source: Internet
Author: User

After deleting the root user in the MySQL users table, we can use the following command to achieve the recovery;

2 ways to start the MySQL database safe mode

1. Modify the configuration file/etc/my.cf, add--skip-grant-tables


2. Use the command to enter Safe mode,

First, you must first close the MySQL services service mysqld stop

Enter Safe Mode Mysqld_safe--skip-grant-tables

3. Add the Use table contents as follows:

mysql> INSERT INTO user set ser= ' root ', ssl_cipher= ', x509_issuer= ', x509_subject= ';

mysql> 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 ', shutd own_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 ';

This article is from the "Linux Small Pot Friends" blog, please be sure to keep this source http://ny0716.blog.51cto.com/9154254/1685624

MySQL database, delete root user after recovery

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.