mysqlaccess


mysqlaccess

mysqlaccess [host] user database [options]

Use this to check privileges of a user for a specific host and database. This utility is executed from the command line, so it can be useful, for instance, as a preliminary tool to check for user permissions before proceeding with a customized program that uses one of the APIs.

With regard to the syntax, the hostname is the first argument and is optional. If not given, localhost is assumed. The username given in the second argument is the name of the user for which the utility is checking privileges. The third argument is the database for which it is checking against. The fourth argument involves several possible options, one of which could be the username by which the utility will access the server to gather information on the user named in the second argument. Here is an example of how you might use this utility:

mysqlaccess localhost marie db1 -U russell -P

In this example, the utility is given the hostname, then the user for which I'm inquiring about, then the database name for which I want user privilege information. The -U option is used to specify the username with which to access the server to gather information. This user has full access to the mysql database. The -P instructs the utility to prompt me for a password. The results of the preceding inquiry is shown here:

Access-rights for USER 'marie', from HOST 'localhost', to DB 'ANY_NEW_DB'         +-----------------+---+ +-----------------+---+         | Select_priv     | Y | | Shutdown_priv   | N |         | Insert_priv     | N | | Process_priv    | N |         | Update_priv     | N | | File_priv       | N |         | Delete_priv     | N | | Grant_priv      | N |         | Create_priv     | N | | References_priv | N |         | Drop_priv       | N | | Index_priv      | N |         | Reload_priv     | N | | Alter_priv      | N |         +-----------------+---+ +-----------------+---+ NOTE:    A password is required for user `reader' :-( The following rules are used: db    : 'No matching rule' host  : 'Not processed: host-field is not empty in db-table.' user:'localhost','marie','6ffa06534985249d','Y','N','N','N', 'N','N','N','N','N','N','N','N','N','N'

First, a table is presented displaying the privileges for the combination of the database named, the host given, and the user. This user has only SELECT privileges.

Additionally, the results are given in raw form for each component. This user's privileges are the same for all databases and hosts (i.e., there are no entries in the db or the host tables in the mysql database), so there aren't any results for those particular components. For the user component, the command displays details without labels, but they are presented in the order that they are found in the user table in the mysql database. The third field is the password in the encrypted format that it stored. The Ys and Ns are the settings for each user privilege.

Several options are available with this utility. Here is an alphabetical list:


--brief, -b

Provides a brief display of results from an inquiry.


--commit

Copies grant rules from temporary tables to the grant tables.


--copy

Reloads temporary tables with original data from the grant tables so that privileges take effect.


--db= database, -d database

Explicitly specifies the database against which to query the user privileges.


--debug= level

Sets the debugging level. The choices are from 0 to 3.


--help, -?

Displays basic help information.


--host= host, -h host

Specifies the host on which to obtain privilege information. The localhost is the default.


--howto

Displays basic examples of usage with sample results.


--old-server

Stipulates that the server to which the utility is connecting is running an older version of MySQL (prior to 3.21) requiring a different method with regard to WHERE clauses in SQL statements.


--password= password, -p password

Provides the password of the user logging into the server, not the user on which to check for privileges.


--plan

Displays plans for further development of the utility by its developers.


--preview

Displays the differences in temporary grant tables before they are committed.


--relnotes

Displays notes on each release of the utility.


--rhost= host, -H host

If the utility is not being run on the same server as the MySQL server that's being queried, use this option to specify the address of the MySQL server to query.


--rollback

Undoes the last change to user privileges.


--spassword= password, -P password

Provides the password when using a superuser.


--superuser= user, -U user

Provides a superuser's username.


--table, -t

Instructs the utility to display data in an ASCII table format.


--user= user, -u user

Provides the username for logging in to the server, not the user on which to check for privileges.


--version, -v

Displays the version of the utility.



MySQL in a Nutshell
MYSQL in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596514336
EAN: 2147483647
Year: 2006
Pages: 134
Authors: Russell Dyer

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net