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 | | ...

Get MySQL in a Nutshell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.