Topic on Project:Support desk

"Cannot access the database" error, intermittent

22
Summary by Ciencia Al Poder

the answer might be in /var/log/mysql/error.log

Anthonyhobday (talkcontribs)

I've got a Mediawiki installation at the following address:

http://www.beforeiplay.com

I see the following error when I visit the address:

http://i.imgur.com/YkI4Fh1.png

If you can't see the image, it reads:

Sorry! This site is experiencing technical difficulties.

Try waiting a few minutes and reloading.

(Cannot access the database)

Here are my installation details:

MediaWiki - 1.25.2

PHP - 5.5.33 (cgi-fcgi)

MariaDB - 10.1.15-MariaDB

Strangely enough, when I go to a specific page, I can see the content:

http://www.beforeiplay.com/index.php?title=Final_Fantasy_10

Even more strangely, sometimes this content is styled, and sometimes it's not, as if the CSS/templates/theme is or isn't loading.

I've even got to the point before where I could visit the main page and not see the error - everything appeared to be working normally.

I've contacted my hosting and apparently no changes have been made to my hosting, nor has anything gone wrong on their end. I've reset the password for the database user and updated it in LocalSettings.php, but that hasn't helped.

Also the fact that it can access content suggests that it's not really the database.

I have not made any changes myself between the time the Wiki was working fine and now.

Kiwkius (talkcontribs)

Turn on Database

Anthonyhobday (talkcontribs)

I don't think this is a serious suggestion, but if it is, you might need to elaborate.

87.123.42.197 (talkcontribs)

The content is unstyled, when the call to load.php, which should in fact return the CSS styles, fails. Btw: It fails with the same error message: Cannot access the database.

I have now purged the cache of the Final Fantasy 10 page and now this page only shows a blank page, nothing else. Anyway, calling the page again afterwards still(?) shows its contents.

Anthonyhobday (talkcontribs)

I have visited other pages on the same wiki and seen styled content, so it seems to be intermittent across pages - not at all consistent.

87.123.42.197 (talkcontribs)

Right now, I also see styled content.

A possibility would be to try connecting to the database e.g. via shell and to see, what error you get there...

I think I once got this kind of error message, when I tried using the same port to connect to two different places. The second one was the database server and that gave me this error. So maybe the database cannot be accessed, because the MariaDB server cannot be reached?

Anthonyhobday (talkcontribs)

I'm not particularly clued up about database administration, but I think from Windows it'd be difficult for me to connect directly to the database. I especially wouldn't know how to check if there are any errors!

87.123.42.197 (talkcontribs)

You can use a tool like Putty to connect to the server and then you try logging in into MariaDB with the database credentials you have. Since the error only happens intermittently, it is important that you try the login exactly at that time, where the wiki shows that the database would not be reachable.

If I should guess, I think this is some kind of configuration problem of your host. I would ask him again to fix that - if his database server is not working correctly, then MediaWiki will not work correctly either.

Anthonyhobday (talkcontribs)

I tried this out, but it turns out I don't have shell access on my hosting account, so I can't connect directly to MariaDB.

However my host have told me that the database server is working fine and I can see the databases when I connect to MySQL admin in the cPanel for the hosting.

Ciencia Al Poder (talkcontribs)

It's strange that it only displays a Cannot access the database error message.

You can try setting $wgShowExceptionDetails to true and see if it gives a more specific reason (connection refused, can't access socket, whatever)

87.123.42.197 (talkcontribs)

> I can see the databases when I connect to MySQL admin in the cPanel for the hosting.

And that at the same time, where MediaWiki says it cannot connect to the database?

Anthonyhobday (talkcontribs)

Yes - at the same time. I get the "cannot connect to database" error about 99% of the time, so it's not hard to check it at the same time that the error is up!

Ciencia: I added this line to LocalSettings.php:

$wgShowExceptionDetails = true;

I still see the same error, and nothing else, when accessing the wiki.

Anthonyhobday (talkcontribs)

I've added PHP error reporting to LocalSettings.php and now I see this when I visit the wiki:

Warning: mysqli::query(): MySQL server has gone away in /home/anthonyh/public_html/beforeiplay/includes/db/DatabaseMysqli.php on line 38

Warning: mysqli::query(): Error reading result set's header in /home/anthonyh/public_html/beforeiplay/includes/db/DatabaseMysqli.php on line 38

Not sure that gives any more help since it seems to just be PHP's way of saying, "Cannot access server".

Ciencia Al Poder (talkcontribs)
Anthonyhobday (talkcontribs)

Hmm - My Wiki database is 26mb, and I certainly wouldn't consider it a large wiki!

Anthonyhobday (talkcontribs)

I added this line to LocalSettings.php:

$wgShowSQLErrors = 1;

And now the error has changed slightly. Not sure if it helps:

(Cannot access the database: Connection refused (localhost))

Anthonyhobday (talkcontribs)

I emailed my host again and they've said that there was a minor update to MariaDB, and other users are reporting issues with Mediawiki databases (Other databases are unaffected).

My host says there's nothing we can do until the people at cPanel look into it (I suppose they're responsible for updating MariaDB?).

87.123.42.197 (talkcontribs)

> the database server is working fine

> they've said that there was a minor update to MariaDB and other users are reporting issues with Mediawiki databases

So much to the host's claim the server would be working fine. They installed a -possibly faulty- update, obviously without testing it properly, and now it's no longer working. The host is responsible for his environment. It is poor behaviour to first make a mistake and to then blame others for it.

JamesPoulson (talkcontribs)

I started getting this today and the site is using MySQL.

First, the "Cannot access the database" message is displayed.

When I reload the page, it sometimes shows content.

However, the sidebar shows the standard links and not the customised ones. The standard Main Page is also displayed instead of the custom one that was set up.

So there's something odd happening here.

JamesPoulson (talkcontribs)

Ok, tried:

$wgShowSQLErrors = 1

And it says:

Too many connections

That looks like a good clue as to what is going on.

91.79.67.34 (talkcontribs)

it may be useful for future interested: the answer might be in /var/log/mysql/error.log

117.20.68.247 (talkcontribs)

Hi, I got this error after upgrading. Not sure what the problem was, however I got around it by creating a new database and user, deleting localsettings.php, doing a fresh/new installation to auto generate a new localsettings file, then changing back to the old database and user in localsettings.