Name
GRANT
Synopsis
GRANT privileges [(columns)][, . . . ] ONdatabase.tableTO'user'*'host'[IDENTIFIED BY [PASSWORD]'password'][, . . . ] [REQUIRE NONE|[{SSL|X509}] [CIPHER'cipher'[AND]] [SUBJECT'subject']] [WITH [GRANT OPTION | MAX_QUERIES_PER_HOURcount| MAX_UPDATES_PER_HOURcount| MAX_CONNECTIONS_PER_HOURcount]]
Use
this statement to create new MySQL users and to grant user
privileges. Privileges can be global (apply to all databases on the
server), database-specific, table-specific, or column-specific. User
information is stored in the grant tables in the
mysql database on the server. Global privileges
are stored in the user table. Database-specific
privileges are stored in the db table. Table
privileges are in the tables_priv table and
column privileges are in the columns_priv table.
You can edit these tables directly with SQL statements, such as
INSERT, UPDATE, and
DROP, followed by a FLUSH
PRIVILEGES statement to update the
server's cache. However, it's
recommended that you use the GRANT statement to
create users and to grant privileges, and the
REVOKE statement to revoke privileges.
In the syntax, the privileges to grant to a user are listed
immediately after the GRANT keyword in a
comma-separated list. Several privileges may be granted to a user. To
give a user all simple user privileges, you can use the ALL
keyword. Here is an example of how you can grant privileges
to a user:
GRANT ALL PRIVILEGES ON *.* TO 'tina'@'localhost' IDENTIFIED BY 'muller' WITH GRANT OPTION; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access