Solve the wrong way to delete all root permissions in MySQL!

Source: Internet
Author: User

Background:

long time to the computer, resulting in "delirious", accidentally in MySQL under the wrong operation of "revoke all on * * from ' root ' @ ' localhost '; ", this command means removing all permissions from the highest-privileged user root in MySQL. Because the password of the native MySQL is empty, although still can go in MySQL, but also illegal to perform the modification operation.


Workaround:

1. First kill the MySQL process

#pkill MySQL

2. Start in--skip-grant-tables mode

#/usr/local/mysql/bin/mysqld_safe--user MySQL--skip-grant-tables&

3. All fields in the updated Mysql.user table are y for n

>use mysql;update user set select_priv = ' Y '  where user =  ' root '; update user set insert_priv = ' Y '  where user =  ' root ';update  user set update_priv = ' Y '  where user =  ' root '; update user set  delete_priv = ' Y '  where user =  ' root '; update user set create_priv  = ' y '  where user =  ' root '; update user set drop_priv = ' y '   where user =  ' root '; update user set reload_priv = ' Y '  where user  =  ' root '; update user set shutdown_priv = ' Y '  where user =  ' Root '; update user set process_priv = ' Y '  where user =  ' root '; update  user set file_priv = ' Y '  where user =  ' root '; update user set  grant_priv = ' Y '  where user =  ' root '; update user set references_priv = ' Y '  where  user =  ' root '; update user set index_priv = ' Y '  where user =   ' root '; update user set alter_priv = ' Y '  where user =  ' root '; update user set show_db_priv = ' Y '  where user =  ' root '; update user  set super_priv = ' Y '  where user =  ' root ';update user set  create_tmp_table_priv = ' Y '  where user =  ' root '; update user set lock_ tables_priv = ' Y '  where user =  ' root '; update user set execute_priv  = ' y '  where user =  ' root '; update user set repl_slave_priv = ' y '  where user =  ' root '; update user set repl_client_priv = ' Y '  where  user =  ' root '; update user set create_view_priv = ' Y '  where user =  ' root ';update  user set show_view_priv = ' Y '  where user =  ' root '; update user set  create_routine_priv = ' Y '  where user =  ' root ';update user set  alter_routine_priv = ' Y '  where user =  ' root '; update user set create_ user_priv = ' y '  where user =  ' root '; update user set event_priv = ' Y '  where user =  ' root '; update user set trigger_priv = ' Y '  where  user =  ' root ';


Summarize:

permission Issues Finally, ensure that host "localhost" and "%" in the "mysql.user" table have all the permissions of root .

The host column is the specified login IP, such as User=root host=192.168.1.1, which means that the root user can only access through 192.168.1.1 's client, and% is a wildcard if host= 192.168.1.%, then it means that as long as the IP is host=192.168.1. Prefix of the client can connect, then the host=% said that all IP has the right to connect, which is why when the remote connection, most people directly changed the host to% of the reason , because it's easy.

This article is from the "Welcome to Linux World" blog, so be sure to keep this source http://linuxnote.blog.51cto.com/9876511/1641488

Solve the wrong way to delete all root permissions in MySQL!

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.