Permissions issues for Mysql database

Source: Internet
Author: User

Have not understood the permissions of MySQL database before

The root user has the highest privileges, that is, the superuser, the root user can see all the contents of the database, and other users can only be the root user authorized to operate the database, if you want to create a new database in other users and not visible to the root user, is not possible, Instead, set the permissions of other users to:

Grant all on * * to ' my_user ' @ ' localhost ';

At this point, the other user's permissions are equivalent to the root user, no practical significance.

Revoke all on * * from ' my_user ' @ ' localhost ';//Reclaim User's permissions

Grant all on db.* to ' my_user ' @ ' localhost ';//grant Operation permissions on DB database only

Grant Select (stu_no) on Db.stu to ' my_user ' @ ' localhost ';//grant only SELECT permission column-level authorization for STU_NO column of Stu table for DB database

SELECT * FROM Mysql.user

To view the user's permissions, note: This time you see the global permissions, that is, the operation of all databases permissions and:

Grant all on * * to ' my_user ' @ ' localhost ';//Grant database permissions, global permissions > Database permissions, and view database permissions when global permissions do not meet conditions

To modify global permissions:

Update mysql.user set create_priv= ' Y ' where user= ' my_user '; error occurs because non-primary keys in MySQL Safe mode cannot perform update and delete operations

Now look at the Mysql.user table:

Desc Mysql.user

In this table, host and user are combined primary keys, so there are two ways to modify them:

①set sql_safe_updates=0;

②update mysql.user set create_priv= ' Y where user= ' My_user ' and host= ' localhost ';

View permissions granted to a specified user

Show grants for ' my_user ' @ ' localhost '

Permissions issues for Mysql 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.