MySQL Tutorial/Privilege/Grant — различия между версиями

Материал из SQL эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 09:49, 26 мая 2010

Add localhost to mysql table for accessing sample_db

mysql>
mysql>
INSERT INTO mysql VALUES("localhost","sample_db","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y");
mysql>


A user doesn"t need a password if connecting from a certain machine

GRANT ALL PRIVILEGES
ON myDatabase.*
TO newuser@192.168.0.2


GRANT ALL

mysql>
mysql>
GRANT ALL ON databaseName.* TO "your_mysql_name"@"your_client_host";


Granting Privileges on the new database

Syntax:



GRANT <privileges>
ON <database>
TO <user>
[IDENTIFIED BY <password>]
[WITH GRANT OPTION]


The items in square brackets are optional.

GRANT OPTION MAX_QUERIES_PER_HOUR 50 MAX_UPDATES_PER_HOUR 50

GRANT SELECT, UPDATE
ON test.*
TO "user1"@"domain1.ru" IDENTIFIED BY "pw1"
WITH GRANT OPTION MAX_QUERIES_PER_HOUR 50 MAX_UPDATES_PER_HOUR 50;


Grant Select and Update privilege to a user

GRANT SELECT, UPDATE (Title, Start_date)
ON test.Employee
TO "user1"@"domain1.ru" IDENTIFIED BY "pw1"
REQUIRE SSL;


GRANT SELECT, UPDATE ON databaseName.*

GRANT SELECT, UPDATE ON databaseName.*
TO "user1"@"domain1.ru" IDENTIFIED BY "pw1"
WITH GRANT OPTION MAX_QUERIES_PER_HOUR 50 MAX_UPDATES_PER_HOUR 50;

mysql>


Grant select, update privilege for a remote user

GRANT SELECT, UPDATE (Title, start_date)
ON test.Employee
TO "user1"@"domain1.ru" IDENTIFIED BY "pw1"
REQUIRE SUBJECT "test client cert."
  AND ISSUER "Test C.A.";


WITH GRANT OPTION condition allows the user to give others privileges to that database

GRANT ALL PRIVILEGES
ON myDatabase.*
TO newuser@localhost
IDENTIFIED BY "newpassword"
WITH GRANT OPTION;


This would allow the user "newuser" to give others privileges to SELECT,INSERT,UPDATE or DELETE.

No user can GRANT more privileges that they themselves possess.