Do some privilege related operation, root user suddenly can't find the system database, lost root user's permission, looked for a long time to solve:
Close the database
Sudo/etc/init.d/mysql stop
Start the Safe Mode database
Mysqld_safe--skip-grant-tables &
Log in to the database, which is now the root user, view the root user
Mysql
> Use MySQL;
> select user,host from User;
Modify root User permissions
update user set ' Select_priv ' = ' Y ', ' Insert_priv ' = ' y ', ' update_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 ', ' alter_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 ' and host= ' localhost ';
Finally restart the database/etc/init.d/mysql restart
If you encounter the forgotten root password can also use the above method to log in to the root account,
update
user
set
authentication_string=
password
(
‘new password‘
)
where
user
=
‘root‘;
This article is from the "Precipitation" blog, please be sure to keep this source http://jupiterbee.blog.51cto.com/3364619/1981109
Ubuntu mysql5.7 Root user does not see the database