Provides you with an in-depth understanding of MySQL user permissions.

Source: Internet
Author: User
Tags mysql command line

MySQL user permissions vary according to the user level. The following section describes the MySQL user permissions, we hope that you will have a better understanding of MySQL user permissions.

You can grant different levels of MySQL user permissions. Global permissions are the most powerful because they apply to any database. To make Etel a Super User who can do anything, including authorizing other users, issue the following statement:

Grant all on *. * TO Etel @ localhost identified by "coffee" WITH GRANT OPTION

*. * In the ON Clause indicates "all databases and all tables ". For security considerations, we specify that Etel can only be connected locally. It is usually wise to restrict the host that a Super User can connect to because it limits the host that tries to crack the password.

Some MySQL user permissions such as FILE, PROCESS, RELOAD, and SHUTDOWN can only be authorized with the "ON *. *" Global permission designation. If you want to, you can grant these permissions without authorizing database permissions. For example, if the following statement sets a flush user, it can only issue flush statements. This may be useful when you need to execute management scripts such as clearing logs:
Grant reload on *. * TO flushl @ localhost identified by "flushpass"

Generally, you want to authorize the permission to manage MySQL users, because users with them can affect the operations on your server.
Database-level permissions apply to all tables in a specific database. They can be granted by using the ON db_name. * clause:

Grant all on samp_db TO bill@racer.snake.net indetified by "rock" GRANT Select ON samp_db TO ro_user @ % indetified by "rock"

The first statement grants permissions to all tables in the samp_db database to bill, and the second statement creates a read-only user ro_user who strictly restricts access). Only all tables in the samp_db database can be accessed, but only tables can be read, that is, you can only issue Select statements.


You can list a series of MySQL user permissions granted at the same time. For example, if you want to allow users to read and modify the content of an existing database but cannot create or delete a new table, grant the following permissions:
GRANT Select, Insert, Delete, Update ON samp_db TO bill@snake.net indetified by "rock"

For more refined access control, you can grant permissions on each table or even on each column of the table. When you want to hide a part of a table from a user, or you want a user to modify only specific columns, column-specific permissions are very useful. For example:

GRANT Select ON samp_db.member TO bill @ localhost indetified by "rock"
GRANT Update (expiration) ON samp_db. member TO bill @ localhost
The first statement grants the read permission to the entire member table and sets a password. The second statement adds the Update permission when only the expiration column is applied. You do not need to specify a password because the first statement has already been specified.
If you want to grant permissions to multiple columns, specify a list separated by commas. For example, to add the Update permission for the address field of the member table to the assistant user, use the following statement to add the new permission to the user's existing permissions:
GRANT Update (street, city, state, zip) ON samp_db TO assistant @ localhost

MySQL user permission setting method

Back up and restore a database using MySQL Command Line

How to process MySQL record duplication

How to query time periods in MySql

Use a MySQL temporary table to accelerate queries

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.