From: Dylan William Hardison Date: Fri, 8 Jul 2016 16:59:29 +0000 (-0400) Subject: Bug 542507 - [PostgreSQL] The db_user sometimes cannot connect to the "template1... X-Git-Tag: release-5.1.2~104 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5880669daea07f078e2bd9deb6e1a0793f6a929f;p=thirdparty%2Fbugzilla.git Bug 542507 - [PostgreSQL] The db_user sometimes cannot connect to the "template1" database --- diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index 6832e0ce71..68582305fc 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -247,7 +247,6 @@ sub _get_no_db_connection { my ($sql_server) = @_; my $dbh; my %connect_params = %{ Bugzilla->localconfig }; - $connect_params{db_name} = ''; my $conn_success = eval { $dbh = _connect(\%connect_params); }; diff --git a/Bugzilla/DB/Pg.pm b/Bugzilla/DB/Pg.pm index 9ef7f77f1c..ed1a4aa7d9 100644 --- a/Bugzilla/DB/Pg.pm +++ b/Bugzilla/DB/Pg.pm @@ -36,14 +36,9 @@ use constant BLOB_TYPE => { pg_type => DBD::Pg::PG_BYTEA }; sub new { my ($class, $params) = @_; - my ($user, $pass, $host, $dbname, $port) = + my ($user, $pass, $host, $dbname, $port) = @$params{qw(db_user db_pass db_host db_name db_port)}; - # The default database name for PostgreSQL. We have - # to connect to SOME database, even if we have - # no $dbname parameter. - $dbname ||= 'template1'; - # construct the DSN from the parameters we got my $dsn = "dbi:Pg:dbname=$dbname"; $dsn .= ";host=$host" if $host; diff --git a/docs/en/rst/installing/postgresql.rst b/docs/en/rst/installing/postgresql.rst index 8e8c4a08bb..10455488c4 100644 --- a/docs/en/rst/installing/postgresql.rst +++ b/docs/en/rst/installing/postgresql.rst @@ -14,8 +14,8 @@ server is started when the machine boots. .. _posgresql-add-user: -Add a User -========== +Add a User and Create a DB +========================== You need to add a new user to PostgreSQL for the Bugzilla application to use when accessing the database. The following instructions @@ -29,12 +29,18 @@ then switch to being the postgres (Unix) user: As the postgres user, you then need to create a new user: -:command:`createuser -U postgres -dRSP bugs` +:command:`createuser -U postgres -DRSP bugs` When asked for a password, provide one and write it down for later reference. The created user will not be a superuser (-S) and will not be able to create -new users (-R). He will only have the ability to create databases (-d). +new users (-R) or create databases (-D). + +Next we will create a database for bugzilla to use + +:command:`createdb -U postgress -O bugs bugs` + +This will create a database named `bugs` that is owned (-O) by the `bugs` user. .. _postgresql-access: diff --git a/template/en/default/setup/strings.txt.pl b/template/en/default/setup/strings.txt.pl index 4b1bc873e9..3adb06b857 100644 --- a/template/en/default/setup/strings.txt.pl +++ b/template/en/default/setup/strings.txt.pl @@ -141,6 +141,7 @@ END localconfig_db_name => <<'END', The name of the database. For Oracle, this is the database's SID. For SQLite, this is a name (or path) for the DB file. +For postgres, this database must already exist and be writable by $db_user. END localconfig_db_pass => <<'END', Enter your database password here. It's normally advisable to specify