Page MenuHomePhabricator

"Cannot access the database: Unknown error (localhost)" after installing Mediawiki-Docker
Open, Needs TriagePublic

Description

I had clone Mediawiki core and set the environment on my localhost with the help of Docker.
I had follow all the steps which were given on Developer.md (https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/master/DEVELOPERS.md).
But when I ran it on my localhost it gave me error.

2020-12-15.png (1×1 px, 307 KB)

Please can anyone help me to resolve this issue?

Event Timeline

@Yash4357 most likely permissions issues on the SQLite database. Can you copy/paste your .env and docker-compose.override.yml files here please?

.env:
MW_DOCKER_PORT=8080
MW_SCRIPT_PATH=/w
MW_SERVER=http://localhost:8080
MEDIAWIKI_USER=Admin
MEDIAWIKI_PASSWORD=dockerpass
XDEBUG_CONFIG=''

docker-compse.yml:
version: '3.7'
services:

mediawiki:
  image: docker-registry.wikimedia.org/dev/stretch-php72-fpm-apache2-xdebug:0.6.1-s1
  working_dir: '/var/www/html/w'
  ports:
    - "${MW_DOCKER_PORT:-8080}:8080"
  volumes:
    - ./:/var/www/html/w:cached
  environment:
    COMPOSER_CACHE_DIR: '/var/www/html/w/cache/composer'
    MW_SERVER: 'http://localhost:${MW_DOCKER_PORT:-8080}'
    MW_SCRIPT_PATH: '/w'
    MW_DBPATH: '/var/www/html/w/cache/sqlite'
    MW_DBTYPE: 'sqlite'
    MW_LANG: 'en'
    MW_USER: 'admin'
    MW_PASS: 'dockerpass'
    MW_SITENAME: 'MediaWiki'
    MW_LOG_DIR: /var/www/html/w/cache
    XDEBUG_CONFIG: ${XDEBUG_CONFIG}
mediawiki-jobrunner:
  image: docker-registry.wikimedia.org/dev/stretch-php72-jobrunner:0.1.0
  volumes:
    - ./:/var/www/html/w:cached
  environment:
    MW_LOG_DIR: /var/www/html/w/cache
    MW_INSTALL_PATH: /var/www/html/w

Thanks. So, no docker-compose.override.yml file, is that right?

And what version of Docker for Windows are you using?

Yes, there is no docker-compose.override.yml file,
And I am using docker version:19.03.13

How did you install Docker? Can you check the file permissions on the cache directory and make sure it's readable by your user?

Do I have to check cache directory of mediawiki?

[22:36:50] <ori> in case Yash4357 comes back, `localhost` doesn't always work within a container. With docker I think you're supposed to use `host.docker.internal` instead of localhost.
This comment was removed by Yash4357.

I have used host.docker.internal but it is showing site can't be reached

I have tried again via host.docker.internal. It give same error.

2020-12-18 (1).png (1×1 px, 302 KB)

host.docker.internal is if you have some need for accessing your host from within the container. If you want to access your MediaWiki site via the browser from your host, you'd use http://localhost:8080 (on Linux or macOS). I'm not sure about the details of Docker for Windows.

Please double check the permissions on the cache directory in the root of the MediaWiki repository, especially the SQLite file(s) inside of it.

Can anyone tell me now, how I can resolve this error?

@Yash4357 Have you tried the re-install directions here? There could be a problem with your LocalSettings file that could cause this.

I have re-install this two times, then also it is not working.

Sorry that did not help. I think many people (including myself) are currently on vacation, so you might not get more responses until after the new year.

Aklapper renamed this task from Cannot access the database: Unknown error (localhost) after installing Mediawiki-Docker to "Cannot access the database: Unknown error (localhost)" after installing Mediawiki-Docker.Jan 1 2021, 8:47 PM

What are the values of $wgDBserver and $wgDBuser in LocalSettings.php? Is $wgDBpassword in LocalSettings.php non-empty?

Database settings:

$wgDBtype = "sqlite";
$wgDBserver = "";
$wgDBname = "my_wiki";
$wgDBuser = "";
$wgDBpassword = "";

This is are the settings.

To be sure: That means all the $wgDBserver, $wgDBuser and $wgDBpassword settings are entirely unset and empty?

Also, what exactly are $wgScriptPath and $wgSQLiteDataDir set to?

$wgSQLiteDataDir = "/var/www/html/w/cache/sqlite";

$wgScriptPath = "/w";

Could you please answer all questions? Thanks. :)

$wgDBserver, $wgDBuser and $wgDBpassword settings are entirely unset and empty.

And $wgScriptPath and $wgSQLiteDataDir set to path as I mentioned above.

$wgDBserver, $wgDBuser and $wgDBpassword settings are entirely unset and empty.

T248359 came to my mind...

I had this exact error when installing MediaWiki-Docker on Windows a month ago. It seems the cache/sqlite directory isn't readable by the MediaWiki inside the MediaWiki Docker container (chmod o+rwx cache/sqlite fixed it)

This was the list of permissions for the directories just after install:

Screenshot 2021-03-24 175200.jpg (520×990 px, 95 KB)

alistair3149 subscribed.

Adding to what @Soda mentioned above:

On the current master branch (1.39), I can consistently reproduce the same problem on Windows no matter how many times I reinstalled the database.
Upon some investigations, I find that there are permission issues with the cache/sqlite folder, changing the permission resolved the issue.

Possibly duplicates: T298050, T305704

Change 836200 had a related patch set uploaded (by Alistair3149; author: Alistair3149):

[mediawiki/core@master] Add Windows-specific instructions in DEVELOPERS.md

https://gerrit.wikimedia.org/r/836200

Shouldn't a Dockerfile be modified to run chmod o+rwx cache/sqlite so the user doesn't run into this error every time and then be required to run it?

Shouldn't a Dockerfile be modified to run chmod o+rwx cache/sqlite so the user doesn't run into this error every time and then be required to run it?

I don't know how to do that so I just added the documentation so that people with Windows setup will be able to use the docker environment for MW development. If someone knows how to implement it in the dockerfile, please feel free to amend this patch or submit another one and I will close this one.

Change 836200 merged by jenkins-bot:

[mediawiki/core@master] Add Windows-specific instructions in DEVELOPERS.md

https://gerrit.wikimedia.org/r/836200

I downloaded the docker-compose.yml from https://github.com/wikimedia/mediawiki/blob/master/docker-compose.yml and I'm trying to modify it to upgrade my existing wikimedia website. First of all, I need to make it work in my local PC and be able to browse the site with the latest (wikimedia/php/apache) versions. The URL should be simple such as http://localhost:8080 So far I did not make it work.

Can someone explain below section of the docker-compose.yml file? Does "/var/www/html/w" mean it will install MW to W: drive?
By policy I'm not allowed to map a new drive at office. Thus I only have access to C: drive. If that's the case, how should I modify this docker compose yaml file?

volumes:

  • ./:/var/www/html/w:cached env_file:
  • '.env' environment: MW_LOG_DIR: /var/www/html/w/cache MW_INSTALL_PATH: /var/www/html/w

Much appreciated!

@Hyang26: Hi and welcome! Please ask general support questions in support forums instead, as your comment seems unrelated to the topic of this bug report. Thanks a lot!

Thanks a lot for your suggestion.
This is the first time I'm using Phabricator.
Will do
Best regards,
Hui