Solution to Mysql database permission loss

Source: Internet
Author: User
Welcome to the Oracle community forum, and interact with 2 million technical staff. To install a software today, you need to use the Mysql database, create a database in it, and users, I followed the script to execute the database creation script. The database was successfully created, but a low-level error occurred while executing user authorization: createdatabasecact

Welcome to the Oracle community forum and interact with 2 million technical staff> to install a software today, you need to use the Mysql database and create a database and corresponding users, I followed the script to execute the database creation script. The database was successfully created, but a low-level error occurred while executing user authorization: create database cact.

Welcome to the Oracle community forum and interact with 2 million technical staff> enter

To install a software today, you need to use the Mysql database. You need to create a database and corresponding users in it. I have executed the database creation script according to the script, and the database has been successfully created, however, a low-level error occurs during user authorization:

Create database cactidb;

Grant all on cactidb. * to root @ localhost;

Grant all on cactidb. * to cactiuser;

This is nothing, but I have already deleted the root @ localhost user. I only left the user with the username root and the host name %, for convenience, I only use root to log on to the local machine. mysql only listens to the address 127.0.0.1. Result 1: grant all on cactidb. * to root @ localhost; this command is finished immediately. I can only log on to the root user as root @ localhost, instead of the common root @ % user, however, root @ localhost basically has no permissions. According to the Mysql authorization mechanism, I can use root @ % only when logging on to other hosts, and I cannot log on from other addresses at all, I am in a hurry. Due to the strict firewall policy, it is impossible for me to open the mysql port. Later, I found relevant information on the Internet and used the following methods to solve the problem:

1. Disable mysql service: service mysqld stop

2../mysqld_safe -- skip-grant-tables restart mysql

3. log on to the Apsara stack console again with the root account. No Password is required.

4. After logging on, delete the root @ local user.

5. Use ps to find the mysqld process and kill it to stop the mysql process.

6. Restart the mysql process: service mysqld start

7. You can also reset the root password by using this method: set password for root = password (yourpass ');

8. You can also reset the root user permission.

Update db set Select_priv = 'y' where user = 'root ';

Update db set Insert_priv = 'y' where user = 'root ';

Update db set Update_priv = 'y' where user = 'root ';

Update db set Delete_priv = 'y' where user = 'root ';

Update db set Create_priv = 'y' where user = 'root ';

Update db set Drop_priv = 'y' where user = 'root ';

Update db set References_priv = 'y' where user = 'root ';

Update db set Grant_priv = 'y' where user = 'root ';

Update db set Index_priv = 'y' where user = 'root ';

Update db set Alter_priv = 'y' where user = 'root ';

Update db set Create_tmp_table_priv = 'y' where user = 'root ';

Update db set Lock_tables_priv = 'y' where user = 'root ';

Update db set Create_view_priv = 'y' where user = 'root ';

Update db set Grant_priv = 'y' where user = 'root ';

Update db set Show_view_priv = 'y' where user = 'root ';

Update db set Create_routine_priv = 'y' where user = 'root ';

Update db set Alter_routine_priv = 'y' where user = 'root ';

Update db set Execute_priv = 'y' where user = 'root ';

Set all the fields of the root user in the mysql. user table to 'y'

Note that the -- skip-grant-tables command cannot be used when mysql is started, so we only need to manually obtain the permission table.

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.