Thursday, June 12, 2008

How to Remove accounts and permissions?


To remove an account, you can use the DROP USER query, which was added in MySQL 4.1.1, as follows:

DROP USER accountname@hostname, accountname@hostname, ...

You must be using an account that has DELETE privileges on the mysql database to execute the DROP USER query.
The behavior of DROP USER has changed through MySQL versions. As of MySQL 5.0.2, it removes the account and all records related to the account, including records that give it permissions on specific databases or tables. However, before MySQL 5.0.2, DROP USER drops only accounts with no privileges. Therefore, in older versions, you must remove all the privileges from an account, including database or table permissions, before you can drop it.
To remove permissions, use the REVOKE query. The general format is

REVOKE permission (columns) ON tablename FROM accountname@hostname

You need to fill in the following information:
  • permission (columns): You must list at least one permission. You can remove each permission from one or more columns by listing the column name in parentheses following the permission. If no column name is listed, the permission is removed from all columns in the table(s). You can list as many permissions/columns as needed, separated by commas. For instance, a REVOKE query might start like this: REVOKE select (firstName,lastName), update, insert (birthdate) ...
  • tablename: Indicate which tables the permission is being removed from. At least one table is required. You can list several tables, separated by commas. The possible values for tablename are
    • tablename: The entire table named tablename in the current database. You can use an asterisk (*) to mean all tables. If you use an asterisk when no current database is selected, the privilege will be revoked on all tables in all databases.
    • databasename.tablename: The entire table named tablename in databasename. You can use an asterisk (*) for either the database name or the table name to mean all. Using . revokes the permission on all tables in all databases.
  • accountname@hostname: The account is identified by the accountname and the hostname as a pair. If an account exists with the specified account name but a different hostname, the REVOKE query will fail, and you will receive an error message. You can remove all the permissions for an account with the following REVOKE query: REVOKE all ON . FROM accountname@hostname

No comments:

 
breast-cancer diabetes-informa... weight-losse lung-mesotheliom... eating-disorders medical-billing php-and-mysql skin-cancer medical-health astronomy-guide cancer-diseases health insurance seo-news-2008 forex3003 lawyer-lookingforalawyer earnmoneyonline-earn forexautotrading-forex forex-trade forextrading forex-trading-forex-trading-08 searchingforcancertreatment adsense jiankang8008 beauty-girl forex5005