# Configuring `%LJ::DBINFO`

# Configuring `%LJ::DBINFO`

`%LJ::DBINFO` is a hash that contains the necessary information for LiveJournal to connect to your database. For installations that require more than one database server, the directives to define each cluster database are also defined here.

## Connection keys

`%LJ::DBINFO` requires a master key that is labelled 'master', and also requires the correct address for connection to the database itself. If you're using a TCP based connection, you can specify a host key with the value of the location of the server, and a port key for the database port (typically 3306). If instead you're using a socket based connection, you can specify a sock key with the value set to the socket file. Specify a user key for your database username, and a password key for your database password. If you used a different database name than the suggested livejournal, you can specify a dbname key with the value of the database name.

## Roles

The role key in `%LJ::DBINFO` is a hash that sets different role keys to the current configuration with boolean values. Roles are basically tasks assigned to the configuration. For example, to set up a server that will host your directory (which can get pretty intensive with a fair amount of users), you would do the following:

    'role' => {
        'directory' => 1,
    },

## Sample `%LJ::DBINFO` hash

    %DBINFO = (
      # master must be named 'master'
      'master' => {
         'host' => "localhost",
         'port' => 3306,
         # or, leave out host/port and use a socket to connect:
         #'sock' => "/var/run/mysqld.sock";
         # optional dbname, if not "livejournal":
         #'dbname' => 'livejournal',
         'user' => 'lj',
         'pass' => 'ljpass',
         'role' => {
             'cluster1' => 1,
         }, },
    );

That's the basic configuration for an installation with only one database server. (FIXME: add link to new section on configuring a site with many database servers)