Page MenuHomePhabricator

When installer fails to connect to a database, let user know if wgDBadminpassword was used
Open, Needs TriagePublic

Description

Steps to Reproduce:

Install MediaWiki 1.32.0 on a host. Configure with MySQL. Set a username and password for the database. MediaWiki will be unable to connect to the remote database.

I noticed this when upgrading from MediaWiki 1.31.1 to 1.32.0. I have MediaWiki installed on one host, and the single instance database server is on another. I have configured a username and password for database access. This works fine with MediaWiki 1.31.1, but does not work with 1.32.0.

The maintenance script fails with a cryptic error:

[b080c820fa73e75fafd9df0a] [no req]   Wikimedia\Rdbms\DBConnectionError from line 1195 of /path/to/w-/includes/libs/rdbms/loadbalancer/LoadBalancer.php: Cannot access the database: Unknown error (example.com)

Enabling additional logging shows the following:

Sat Mar 9 14:11:45 UTC 2019     wiki.example.com     wtpa_mediawiki  Error connecting to example.com: :real_connect(): (HY000/1045): Access denied for user 'user'@'wiki.example.com' (using password: NO)

However, my LocalSettings.php has $wgDBpassword set, and the configuration works fine with MediaWiki 1.31.1.

Actual Results:

Error connecting to database.

Expected Results:

No error connecting to database.

Event Timeline

Any thoughts on this one? I still cannot update to MediaWiki 1.32.0 because of this issue.

@mhoran The error "Access denied for user 'user'@'wiki.example.com' (using password: no)" comes from your MySQL server and usually indicates that the username/password given are incorrect. I'm not sure where this could lead to an issue in MediaWiki, but it is possible of course.

A few questions that might help narrow it down:

  • Which version of PHP does this involve?
  • Which version of MySQL are you using? (check "Special:Version" via the previous MW version)

Also, can you provide a summary of all DB-related settings you use in LocalSettings? (with any private information simplified, but keep the general shape, such that value still look like the same kind of value, like sock file path, IP address, internal/public host name, empty string, not empty string, etc.).

@Krinkle thanks for the reply. I do understand that this message comes from the MySQL server. However, I believe there is a bug in MediaWiki here and now an issue with my configuration. I only encounter this issue when upgrading from 1.31.1 to 1.32.0. I have the same LocalSettings.php between the two, and 1.32.0 seems to ignore the password that I have configured in LocalSettings.php. If I run the same LocalSettings.php with 1.31.1, all is fine.

The PHP version is 7.2.16. The MySQL version is 5.7. I am use Google's Cloud SQL. However, I also encountered this when running MySQL myself. When running on localhost with either a UNIX domain socket or no password on a TCP connection, MediaWiki can connect to the database. However, I'm not willing to add a passwordless user to my Cloud SQL instance, hence encountering this issue.

It's rather easy to reproduce; simply set up a Cloud SQL database and attempt to use MediaWiki with the instance. It will fail with the above error. I even get this when trying to run the installer. I did notice some refactoring around the connection handling between 1.31.1 and 1.32.0; however I did not want to dive in deep to figure out what may have changed. I believe there may be an issue with how highly-available MySQL and single-node MySQL is handled. I have a single-node MySQL instance, with the associated single-node settings.

Here are the relevant bits from my LocalSettings.php:

## Database settings
$wgDBtype           = "mysql";
$wgDBserver         = "127.0.0.1";
$wgDBname           = "wtpa_mediawiki";
$wgDBuser           = "wtpa";
$wgDBpassword       = "password";

Can you confirm that none of the below variables are changes in your LocalSettings.php file, StartProfiler.php file, or other files/extensions included from LocalSettings? That is to say, when checking them via maintenance/eval.php on the working MW 1.31.1 install, they have their default values?

$wgDBprefix

$wgDBport
$wgDBssl
$wgDBcompress
$wgDBadminuser
$wgDBadminpassword
$wgDBTableOptions
$wgSQLMode
$wgDBmwschema

$wgSharedDB
$wgSharedPrefix
$wgSharedTables
$wgSharedSchema

$wgDBservers

$wgLBFactoryConf

Also, regarding $wgDBserver, do you use 127.0.0.1, any other IP address, or a hostname?

I couldn't get maintenance/eval.php to show anything (perhaps why this worked fine in 1.31.1), however upon inspection, my LocalSettings.php did have a $wgDBadminuser and $wgDBadminpassword. $wgDBadminpassword was blank, which must be why this wasn't working. I removed both $wgDBadminuser and $wgDBadminpassword and was able to upgrade to 1.32.0!

Aklapper renamed this task from MediaWiki 1.32.0 installed on host A cannot authenticate to MySQL on host B with password to 1.32.0 installed on host A cannot authenticate to MySQL on host B with password when $wgDBadminpassword is blank in LocalSettings.php.Apr 4 2019, 8:17 AM

In hindsight, I think this was mostly my fault. Between upgrading from 1.30.1 to 1.32.0 I also changed SQL providers and set a password for my MediaWiki user. I still had the $wgDBadminuser and $wgDBadminpassword from the days of AdminSettings.php and didn't realize that they were no longer necessary.

If the installer gave an error like $wgDBadminpassword does not equal $wgDBpassword then it would have been a lot clearer. Also complicating the situation is that there was no useful output whatsoever until I enabled debugging; the message from update.php was rather unhelpful.

I guess there may be legitimate reasons for having different $wgDBadminuser and $wgDBadminpassword, but perhaps if $wgDBadminuser == $wgDBuser the above info message could be printed.

I guess there may be legitimate reasons for having different $wgDBadminuser and $wgDBadminpassword, but perhaps if $wgDBadminuser == $wgDBuser the above info message could be printed.

Yes, Wikipedia has these configured differently for security reasons. The MySQL (or MaraDB) database user for regular web server traffic does not have the permission to drop tables or perform schema changes.

For an admin that is comfortable creating the regular database user themselves, I'd recommend doing this at the same time as well. Should only take a minute to set up and eliminates a major source of potential security issues. On the other hand for someone using a shared host where a database user exists already, creating a new db user and can be challenging as it depends on their specific environment (we can't help them easily). E.g. involving some kind of control panel from their provider to create a new user etc., and then editing LocalSettings to set it up (which may also be difficult, if they've only used the web interface to install MediaWiki).

Krinkle renamed this task from 1.32.0 installed on host A cannot authenticate to MySQL on host B with password when $wgDBadminpassword is blank in LocalSettings.php to When installer fails to connect to a database, let user know if wgDBadminpassword was used.Apr 19 2019, 5:30 PM
Krinkle edited projects, added MediaWiki-Installer; removed MediaWiki-libs-Rdbms.
Krinkle changed the subtype of this task from "Bug Report" to "Task".