KEMBAR78
Tutor Mysql Part 5 Gop | PDF
0% found this document useful (0 votes)
11 views1 page

Tutor Mysql Part 5 Gop

The document provides instructions on creating a user in a database and assigning permissions. It details how to create users with specific connection privileges and how to grant various levels of access to databases and tables. Additionally, it explains the implications of using the 'WITH GRANT OPTION' when assigning privileges.

Uploaded by

Irfan Pordjo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

Tutor Mysql Part 5 Gop

The document provides instructions on creating a user in a database and assigning permissions. It details how to create users with specific connection privileges and how to grant various levels of access to databases and tables. Additionally, it explains the implications of using the 'WITH GRANT OPTION' when assigning privileges.

Uploaded by

Irfan Pordjo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Key refers to the type of key that may affect the field. Primary (PRI), Unique (UNI) ...

n row in set (0.00 sec)

Where n is the number of fields in the table.

Creating user

First, you need to create a user and then give the user permissions on certain databases/tables.
While creating the user, you also need to specify where this user can connect from.

CREATE USER 'user'@'localhost' IDENTIFIED BY 'some_password';

Will create a user that can only connect on the local machine where the database is hosted.

CREATE USER 'user'@'%' IDENTIFIED BY 'some_password';

Will create a user that can connect from anywhere (except the local machine).

Example return value:

Query OK, 0 rows affected (0.00 sec)

Adding privileges

Grant common, basic privileges to the user for all tables of the specified database:

GRANT SELECT, INSERT, UPDATE ON databaseName.* TO 'userName'@'localhost';

Grant all privileges to the user for all tables on all databases (attention with this):

GRANT ALL ON *.* TO 'userName'@'localhost' WITH GRANT OPTION;

As demonstrated above, *.* targets all databases and tables, databaseName.* targets all tables of
the specific database. It is also possible to specify database and table like so
databaseName.tableName.

WITH GRANT OPTION should be left out if the user need not be able to grant other users privileges.

Privileges can be either

ALL

or a combination of the following, each separated by a comma (non-exhaustive list).

SELECT
INSERT
UPDATE
DELETE

https://riptutorial.com/ 6

You might also like