Topic on Project:Support desk

Reporting that "(Cannot access the database)" though I can connect via terminal to mysql.

12
Jamiehutber (talkcontribs)

I believe this is not actually a connect issue, as I can see "title-invalid-e" and I can connect with the same credentials found in my LocalSettings.php file.

Any help would be much appreciated.

http://gwart.co.uk/

Sorry! This site is experiencing technical difficulties.

Try waiting a few minutes and reloading.

(Cannot access the database)

Backtrace:

#0 /var/www/gwart.co.uk/mediawiki/includes/libs/rdbms/loadbalancer/LoadBalancer.php(753): Wikimedia\Rdbms\LoadBalancer->reportConnectionError()
#1 /var/www/gwart.co.uk/mediawiki/includes/GlobalFunctions.php(2653): Wikimedia\Rdbms\LoadBalancer->getConnection(0, Array, false)
#2 /var/www/gwart.co.uk/mediawiki/includes/cache/localisation/LCStoreDB.php(54): wfGetDB(-1)
#3 /var/www/gwart.co.uk/mediawiki/includes/cache/localisation/LocalisationCache.php(410): LCStoreDB->get('en', 'deps')
#4 /var/www/gwart.co.uk/mediawiki/includes/cache/localisation/LocalisationCache.php(456): LocalisationCache->isExpired('en')
#5 /var/www/gwart.co.uk/mediawiki/includes/cache/localisation/LocalisationCache.php(375): LocalisationCache->initLanguage('en')
#6 /var/www/gwart.co.uk/mediawiki/includes/cache/localisation/LocalisationCache.php(294): LocalisationCache->loadSubitem('en', 'messages', 'title-invalid-e...')
#7 /var/www/gwart.co.uk/mediawiki/languages/Language.php(2640): LocalisationCache->getSubitem('en', 'messages', 'title-invalid-e...')
#8 /var/www/gwart.co.uk/mediawiki/includes/cache/MessageCache.php(984): Language->getMessage('title-invalid-e...')
#9 /var/www/gwart.co.uk/mediawiki/includes/cache/MessageCache.php(942): MessageCache->getMessageForLang(Object(LanguageEn), 'title-invalid-e...', false, Array)
#10 /var/www/gwart.co.uk/mediawiki/includes/cache/MessageCache.php(884): MessageCache->getMessageFromFallbackChain(Object(LanguageEn), 'title-invalid-e...', false)
#11 /var/www/gwart.co.uk/mediawiki/includes/Message.php(1312): MessageCache->get('title-invalid-e...', false, Object(LanguageEn))
#12 /var/www/gwart.co.uk/mediawiki/includes/Message.php(864): Message->fetchMessage()
#13 /var/www/gwart.co.uk/mediawiki/includes/Message.php(956): Message->toString('text')
#14 /var/www/gwart.co.uk/mediawiki/includes/title/MalformedTitleException.php(49): Message->text()
#15 /var/www/gwart.co.uk/mediawiki/includes/title/MediaWikiTitleCodec.php(297): MalformedTitleException->__construct('title-invalid-e...', '')
#16 /var/www/gwart.co.uk/mediawiki/includes/Title.php(3752): MediaWikiTitleCodec->splitTitleString('', 0)
#17 /var/www/gwart.co.uk/mediawiki/includes/Title.php(378): Title->secureAndSplit()
#18 /var/www/gwart.co.uk/mediawiki/includes/MediaWiki.php(83): Title::newFromURL('')
#19 /var/www/gwart.co.uk/mediawiki/includes/MediaWiki.php(140): MediaWiki->parseTitle()
#20 /var/www/gwart.co.uk/mediawiki/includes/MediaWiki.php(778): MediaWiki->getTitle()
#21 /var/www/gwart.co.uk/mediawiki/includes/MediaWiki.php(517): MediaWiki->main()
#22 /var/www/gwart.co.uk/mediawiki/index.php(42): MediaWiki->run()
#23 {main}
Bawolff (talkcontribs)

it probably is one. Check your mysql is setup to use password based authentication

Jamiehutber (talkcontribs)

Thanks very much @Bawolff for the reply!!

I am able to connect to the mysql with a pass in CLI.

So this means that I cannot connect to the db for some reason, which there is no end to why. Though I could previously without any problems.

But it is certainly not a username/password issue.

Bawolff (talkcontribs)

> I am able to connect to the mysql with a pass in CLI.

Can you connect with the same username/password that MediaWiki is configured to use in LocalSettings.php ? Can you connect to the database when using the sql.php maintenance script from the command line?

Have you upgraded mysql recently? Have you upgraded php recently? Are you using SELinux or similar security tools that might block php from accessing the database (If so, check their logs)?

Jamiehutber (talkcontribs)

Thanks again!!


> Can you connect with the same username/password that MediaWiki is configured to use in LocalSettings.php ?

I can connect with these details

> sql.php

[9c50504668796b7bedf5c5c9] [no req]   Wikimedia\Rdbms\DBConnectionError from line 1195 of /var/www/gwart.co.uk/mediawiki/includes/libs/rdbms/loadbalancer/LoadBalancer.php: Cannot access the database: Unknown error (mysql)

Backtrace:

#0 /var/www/gwart.co.uk/mediawiki/includes/libs/rdbms/loadbalancer/LoadBalancer.php(753): Wikimedia\Rdbms\LoadBalancer->reportConnectionError()

#1 /var/www/gwart.co.uk/mediawiki/maintenance/sql.php(85): Wikimedia\Rdbms\LoadBalancer->getConnection(integer, array, boolean)

#2 /var/www/gwart.co.uk/mediawiki/maintenance/doMaintenance.php(94): MwSql->execute()

#3 /var/www/gwart.co.uk/mediawiki/maintenance/sql.php(205): require_once(string)

#4 {main}

Which is clearly a connection issue as you say.


> Have you upgraded mysql recently? Have you upgraded php recently?

Very good question, I do believe I downgraded my php version from 7.4 to 7.0.


> Are you using SELinux or similar security tools that might block php from accessing the database (If so, check their logs)?

I have other sites on the same server that is connecting to the DB. Which adds to my confusion.

Jamiehutber (talkcontribs)

Any other thoughts :) I would love to fix this. Thanks still for all the help you've given me

Jamiehutber (talkcontribs)

I wonder if there is any way to restore to an earlier time directly in the DB?

Jamiehutber (talkcontribs)

Could it be as simple as a DB issue, though I am certain I have fixed this now.


Bawolff (talkcontribs)

Its an error connecting to the DB, so its probably not an issue in regards to the content of your database. It may be an issue with the administration of your db (Like what processes it accepts connections from and other user rights things) or it may be a problem on the php side.

130.238.68.12 (talkcontribs)

I had this error after upgrading.

What i found out was that the line

$wgDBport           = "5432";

in LocalSettings.php that appeared under the heading

# Postgres specific settings

in the updated version, is no longer a Postgres specific settings and applies to MySQL as well, so after upgrading mediawiki tried to access MySQL on the Postgres port and failed.

Commenting out the "Postgres specific settings", made the MySQL connection work.

128.231.234.80 (talkcontribs)

For anyone else that comes across this error. For me it was selinux.

- If your website is saying "(Cannot access the database)"

- You CAN connect to mysql like: mysql -u [username] -p -h [host] [database]

- If you CAN run: php maintenance/sql.php --query "SELECT user_name from user;"

Then it might be selinux.

To check: getenforce

- May return "Enforcing"

You may need to tess selinux to allow http to connect to a database. to do so:

- setsebool -P httpd_can_network_connect 1

- setsebool -P httpd_can_network_connect_db 1

128.231.234.80 (talkcontribs)

err, tell.

Reply to "Reporting that "(Cannot access the database)" though I can connect via terminal to mysql."