O'Reilly logo

MySQL in a Nutshell by Russell J.T. Dyer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

mysqlaccess

Synopsis

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required