Adding
and Removing Privileges: [See
in MySQL Manual 4.2]
To add user privileges use the GRANT command:
GRANT privileges
[columns]
ON [ * | *.* | dbanme.* | table_name
]
TO user_name [
IDENTIFIED BY 'password'
]
[ WITH GRANT
OPTION ]
To remove user privileges use the REVOKE command:
REVOKE privileges
[columns]
ON [ * | *.* | dbanme.* | table_name
]
FROM user_name
A list of Privileges for Users:
SELECT, INSERT, UPDATE, DELETE, ALTER, CREATE, DROP
Note: If wishing to allow a user access to all privileges
use the key word 'ALL'
Reloading the User Privileges:
If you have add or removed any user privleges you must
reload the user privileges or MySQL will not see the
changes.
C:\mysql\bin> mysqladmin reload
or from inside mysql
mysql> FLUSH PRIVILEGES;
Examples:
Grant all privileges on all databases to a user called
Fred.
mysql> GRANT all
mysql> on
*
mysql>
to fred identified by 'hi1234';
Grant
all privileges on a database called 'webpc' to a user
called Fred.
mysql> GRANT all
mysql> on
webpc.*
mysql>
to fred identified by 'hi1234';
Grant
select, insert, delete and update privileges on a database
called 'webpc' to a user called Fred.
mysql> GRANT select, insert,
delete, update
mysql> on
webpc.*
mysql>
to fred identified by 'hi1234';
Revoke
all privileges on all databases to a user called Fred.
mysql> REVOKE all
mysql> on
*
mysql>
from fred;
|