From 2d38eb1650daddb7b94f39daae1f1634fea5e5b1 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 28 Sep 2015 16:29:01 +0200 Subject: [PATCH] Document that it's possible to use unix domain sockets for MySQL and PostgreSQL connections fixes #9787 --- .../forms/Config/Resource/DbResourceForm.php | 25 ++++++++++++++-- doc/resources.md | 29 +++++++++++++++---- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/application/forms/Config/Resource/DbResourceForm.php b/application/forms/Config/Resource/DbResourceForm.php index d79ad248b..407bb13ff 100644 --- a/application/forms/Config/Resource/DbResourceForm.php +++ b/application/forms/Config/Resource/DbResourceForm.php @@ -43,12 +43,30 @@ class DbResourceForm extends Form $dbChoices['oci'] = 'Oracle (OCI8)'; } $offerPostgres = false; + $offerMysql = false; if (isset($formData['db'])) { if ($formData['db'] === 'pgsql') { $offerPostgres = true; + } elseif ($formData['db'] === 'mysql') { + $offerMysql = true; } - } elseif (key($dbChoices) === 'pgsql') { - $offerPostgres = true; + } else { + $dbChoice = key($dbChoices); + if ($dbChoice === 'pgsql') { + $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( 'text', @@ -76,7 +94,8 @@ class DbResourceForm extends Form array ( 'required' => true, 'label' => $this->translate('Host'), - 'description' => $this->translate('The hostname of the database'), + 'description' => $this->translate('The hostname of the database') + . ($socketInfo ? '. ' . $socketInfo : ''), 'value' => 'localhost' ) ); diff --git a/doc/resources.md b/doc/resources.md index a2bfb66af..6b43ca3d3 100644 --- a/doc/resources.md +++ b/doc/resources.md @@ -19,21 +19,38 @@ to handle authentication and authorization, monitoring data or user preferences. Directive | Description ----------------|------------ **type** | `db` -**db** | Database management system. Either `mysql` or `pgsql`. -**host** | Connect to the database server on the given host. -**port** | Port number to use for the connection. +**db** | Database management system. In most cases `mysql` or `pgsql`. +**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. Mandatory for connections to a PostgreSQL database. **username** | The username to use when connecting to the server. **password** | The password to use when connecting to the server. **dbname** | The database to use. **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 db = mysql 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 password = icingaweb dbname = icingaweb