MySQL Tutorial/Privilege/Grant
Содержание
- 1 Add localhost to mysql table for accessing sample_db
- 2 A user doesn"t need a password if connecting from a certain machine
- 3 GRANT ALL
- 4 Granting Privileges on the new database
- 5 GRANT OPTION MAX_QUERIES_PER_HOUR 50 MAX_UPDATES_PER_HOUR 50
- 6 Grant Select and Update privilege to a user
- 7 GRANT SELECT, UPDATE ON databaseName.*
- 8 Grant select, update privilege for a remote user
- 9 WITH GRANT OPTION condition allows the user to give others privileges to that database
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.