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!