Document that it's possible to use unix domain sockets for MySQL and PostgreSQL connections

fixes #9787
This commit is contained in:
Eric Lippmann 2015-09-28 16:29:01 +02:00
parent 411b0cf3ac
commit 2d38eb1650
2 changed files with 45 additions and 9 deletions

View File

@ -43,12 +43,30 @@ class DbResourceForm extends Form
$dbChoices['oci'] = 'Oracle (OCI8)'; $dbChoices['oci'] = 'Oracle (OCI8)';
} }
$offerPostgres = false; $offerPostgres = false;
$offerMysql = false;
if (isset($formData['db'])) { if (isset($formData['db'])) {
if ($formData['db'] === 'pgsql') { if ($formData['db'] === 'pgsql') {
$offerPostgres = true; $offerPostgres = true;
} elseif ($formData['db'] === 'mysql') {
$offerMysql = true;
} }
} elseif (key($dbChoices) === 'pgsql') { } else {
$dbChoice = key($dbChoices);
if ($dbChoice === 'pgsql') {
$offerPostgres = true; $offerPostgres = true;
} elseif ($dbChoices === 'mysql') {
$offerMysql = true;
}
}
$socketInfo = '';
if ($offerPostgres) {
$socketInfo = $this->translate(
'For using unix domain sockets, specify the path to the unix domain socket directory'
);
} elseif ($offerMysql) {
$socketInfo = $this->translate(
'For using unix domain sockets, specify localhost'
);
} }
$this->addElement( $this->addElement(
'text', 'text',
@ -76,7 +94,8 @@ class DbResourceForm extends Form
array ( array (
'required' => true, 'required' => true,
'label' => $this->translate('Host'), 'label' => $this->translate('Host'),
'description' => $this->translate('The hostname of the database'), 'description' => $this->translate('The hostname of the database')
. ($socketInfo ? '. ' . $socketInfo : ''),
'value' => 'localhost' 'value' => 'localhost'
) )
); );

View File

@ -19,21 +19,38 @@ to handle authentication and authorization, monitoring data or user preferences.
Directive | Description Directive | Description
----------------|------------ ----------------|------------
**type** | `db` **type** | `db`
**db** | Database management system. Either `mysql` or `pgsql`. **db** | Database management system. In most cases `mysql` or `pgsql`.
**host** | Connect to the database server on the given host. **host** | Connect to the database server on the given host. For using unix domain sockets, specify `localhost` for MySQL and the path to the unix domain socket directory for PostgreSQL.
**port** | Port number to use for the connection. **port** | Port number to use. Mandatory for connections to a PostgreSQL database.
**username** | The username to use when connecting to the server. **username** | The username to use when connecting to the server.
**password** | The password to use when connecting to the server. **password** | The password to use when connecting to the server.
**dbname** | The database to use. **dbname** | The database to use.
**Example:** **Example:**
``` ````
[icingaweb] [icingaweb-mysql-tcp]
type = db
db = mysql
host = 127.0.0.1
port = 3306
username = icingaweb
password = icingaweb
dbname = icingaweb
[icingaweb-mysql-socket]
type = db type = db
db = mysql db = mysql
host = localhost host = localhost
port = 3306 username = icingaweb
password = icingaweb
dbname = icingaweb
[icingaweb-pgsql-socket]
type = db
db = pgsql
host = /var/run/postgresql
port = 5432
username = icingaweb username = icingaweb
password = icingaweb password = icingaweb
dbname = icingaweb dbname = icingaweb