== link:index.html[Index] -> link:modules.html[Modules] -> link:modules_validators.html[Validators]

Validator: Mysql
~~~~~~~~~~~~~~~~

The MySQL validator allows you to authenticate a user against a MySQL database.

[[parameters]]
.Parameters
[cols="20%,80%",options="header"]
|===================================================================
|Parameter       |Description
|__host__        |Optional. The server that is running the MySQL
                  database server. Default: __localhost__.
|__port__        |Optional. The port that MySQL is listening on.
                  Default: __3306__.
|__unix_socket__ |Optional. A Unix socket.
|__user__        |The MySQL user to authenticate as.
|__passwd__      |The MySQL user password to use.
|__database__    |Required. The MySQL database to select upon
                  connection.
|__query__       |Required. The query to execute to authenticate
                  the HTTP user.
|__hash__        |Optional. What the passwords in the database table
                  are hashed with. Valid options are __sha1__
                   __md5__ or __none__. Default: __none__.
|===================================================================

The `query` parameter is given an argument `$\{user}` so you can query
against it.

.Sample query
----
    SELECT password FROM auth_users WHERE username = '${user}'
----
The query must return one row with one column as the password.  The name of the
column does not matter.

[[compatibility]]
Compatibility
^^^^^^^^^^^^^
This validator is compatible with both **basic** and **digest** schemes.

