DB - Database connections

The following configuration variables can be used to configure settings for the connection to the database:

additionalQueryRestrictions

$GLOBALS['TYPO3_CONF_VARS']['DB']['additionalQueryRestrictions']
type

array

Default

[]

It is possible to add additional query restrictions by adding class names as key to $GLOBALS['TYPO3_CONF_VARS']['DB']['additionalQueryRestrictions']. Have a look into the chapter Custom restrictions for details.

Connections

$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']
type

array

One or more database connections can be configured under the Connections key. There must be at least one configuration with the Default key, in which the default database is configured, for example:

typo3conf/LocalConfiguration.php
'Connections' => [
    'Default' => [
        'charset' => 'utf8mb4',
        'driver' => 'mysqli',
        'dbname' => 'typo3_database',
        'host' => '127.0.0.1',
        'password' => 'typo3',
        'port' => 3306,
        'user' => 'typo3',
    ],
]
Copied!

It is possible to swap out tables from the default database and use a specific setup (for instance, for caching). For example, the following snippet could be used to swap the be_sessions table to another database or even another database server:

typo3conf/LocalConfiguration.php
'Connections' => [
    'Default' => [
        'charset' => 'utf8mb4',
        'driver' => 'mysqli',
        'dbname' => 'typo3_database',
        'host' => '127.0.0.1',
        'password' => '***',
        'port' => 3306,
        'user' => 'typo3',
    ],
    'Sessions' => [
        'charset' => 'utf8mb4',
        'driver' => 'mysqli',
        'dbname' => 'sessions_dbname',
        'host' => 'sessions_host',
        'password' => '***',
        'port' => 3306,
        'user' => 'some_user',
    ],
],
'TableMapping' => [
    'be_sessions' => 'Sessions',
]
Copied!

charset

$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections'][<connection_name>]['charset']
type

string

Default

'utf8'

The charset used when connecting to the database. Can be used with MySQL/MariaDB and PostgreSQL.

dbname

$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections'][<connection_name>]['dbname']
type

string

Name of the database/schema to connect to. Can be used with MySQL/MariaDB and PostgreSQL.

driver

$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections'][<connection_name>]['driver']
type

string

The built-in driver implementation to use. The following drivers are currently available:

mysqli
A MySQL/MariaDB driver that uses the mysqli extension.
pdo_mysql
A MySQL/MariaDB driver that uses the pdo_mysql PDO extension.
pdo_pgsql
A PostgreSQL driver that uses the pdo_pgsql PDO extension.
pdo_sqlite
An SQLite driver that uses the pdo_sqlite PDO extension.

host

$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections'][<connection_name>]['host']
type

string

Hostname or IP address of the database to connect to. Can be used with MySQL/MariaDB and PostgreSQL.

password

$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections'][<connection_name>]['password']
type

string

Password to use when connecting to the database.

path

$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections'][<connection_name>]['path']
type

string

The filesystem path to the SQLite database file.

port

$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections'][<connection_name>]['port']
type

string

Port of the database to connect to. Can be used with MySQL/MariaDB and PostgreSQL.

tableoptions

$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections'][<connection_name>]['tableoptions']
type

array

Default

[]

Defines the charset and collate options for tables for MySQL/MariaDB:

typo3conf/LocalConfiguration.php
'Connections' => [
    'Default' => [
        'driver' => 'mysqli',
        // ...
        'charset' => 'utf8mb4',
        'tableoptions' => [
            'charset' => 'utf8mb4',
            'collate' => 'utf8mb4_unicode_ci',
        ],
    ],
]
Copied!

For new installations the above is the default.

unix_socket

$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections'][<connection_name>]['unix_socket']
type

string

Name of the socket used to connect to the database. Can be used with MySQL/MariaDB.

user

$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections'][<connection_name>]['user']
type

string

Username to use when connecting to the database.

TableMapping

$GLOBALS['TYPO3_CONF_VARS']['DB']['TableMapping']
type

array

Default

[]

When a TYPO3 table is swapped to another database (either on the same host or another host) this table must be mapped to the other database.

For example, the be_sessions table should be swapped to another database:

typo3conf/LocalConfiguration.php
'Connections' => [
    'Default' => [
        // ...
    ],
    'Sessions' => [
        'charset' => 'utf8mb4',
        'driver' => 'mysqli',
        'dbname' => 'sessions_dbname',
        'host' => 'sessions_host',
        'password' => '***',
        'port' => 3306,
        'user' => 'some_user',
    ],
],
'TableMapping' => [
    'be_sessions' => 'Sessions',
]
Copied!