You can see the current permissions for an account with the following query:
SHOW GRANTS ON accountname@hostname
The output is a GRANT query that would create the current account. It shows all the current permissions. If you do not include the ON clause, you see the current permissions for the account that issued the SHOW GRANTS query. You can change permissions for an account with the GRANT query, which has the following general format:
GRANT permission (columns) ON tablename TO accountname@hostname IDENTIFIED BY ‘password’
You can also create a new account or change a password with the GRANT query. You need to fill in the following information:
- permission (columns): You must list at least one permission. You can limit each permission to one or more columns by listing the column name in parentheses following the permission. If no column name is listed, the permission is granted on all columns in the table(s). You can list as many permissions and columns as needed, separated by commas. For instance, a GRANT query might start with this: GRANT select (firstName,lastName), update, insert (birthdate) ...
- tablename: This indicates which tables the permission is granted on. 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 in the current database. If you use an asterisk and no current database is selected, the privilege will be granted to all tables on 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 . grants the permission on all tables in all databases.
- accountname@hostname: If the account already exists, it is given the indicated permissions. If the account doesn’t exist, it’s added. 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 existing account is not changed; a new one is created.
- password: This is the password that you’re adding or changing. A password is not required. If you don’t want to add or change a password for this account, leave out the phrase IDENTIFIED BY ‘password’. The GRANT query to add a new account for use in the PHP programs for the PetCatalog database might be GRANT select ON PetCatalog.* TO phpuser@localhost IDENTIFIED BY ‘A41!14a!’
No comments:
Post a Comment