Ubuntu mysql5.7 Root user does not see the database

Source: Internet
Author: User

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:

    1. Close the database

      Sudo/etc/init.d/mysql stop

    2. Start the Safe Mode database

      Mysqld_safe--skip-grant-tables &

    3. Log in to the database, which is now the root user, view the root user

      Mysql

      > Use MySQL;

      > select user,host from User;

    4. 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,

updateuser set authentication_string=password(‘new password‘) whereuser=‘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

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.