Page MenuHomePhabricator

Cannot access the database: :real_connect(): (HY000/2002): No such file or directory. (due to "Database host" entry being "localhost" instead of "database")
Open, Needs TriagePublicBUG REPORT

Description

Steps to Reproduce:

I followed this guide:
https://wiki.chairat.me/books/docker/page/how-to-setup-mediawiki-with-docker

Actual Results:

The configuration phase does not recognize the mysql db

Event Timeline

Aklapper changed the task status from Open to Stalled.Jun 3 2020, 9:26 PM
Aklapper removed a project: MediaWiki-Docker.

Hi @Manang! You are free to follow random web pages written by random folks about ancient software versions, but that's not something we can support here. :)

Please see https://www.mediawiki.org/wiki/How_to_report_a_bug if you think that there is some software bug somewhere, and include:

  • a clear list of exact steps to reproduce the situation, step by step, so that nobody needs to guess or interpret how you performed each step,
  • what happens after performing these steps to reproduce,
  • what you expected to happen instead,

You can edit the task description by clicking Edit Task. Ideally, a good description should allow any other person to follow these steps (without having to interpret steps) and see the same results. Problems that others can reproduce can get fixed faster. Thanks!

Hi,
sorry if I followed the wrong guide.

I followerd the official guide, too
https://hub.docker.com/_/mediawiki

I tried with docker compose, but nothing, during the first configuration it is impossible to connect the db to the mediawiki project.

I used the same stack.yml file, with the same password and user
During the configuration I used localhost as url of the db.

I optioned the following message:

Cannot access the database: :real_connect(): (HY000/2002): No such file or directory. Check the host, username and password and try again. If using "localhost" as the database host, try using "127.0.0.1" instead (or vice versa).

Ideas?

I think tha the two guides are equivalents

Angelo

@Manang: Please see my previous comment: Please provide a complete (!) list (!) of steps, as a list, with commands, which lead to that error message.

Hi,
my version of docker: 2.3.0.3 (45519)
host: mac os x 10.15.5

the steps are:
I create the stack.yml file with the following content:

# MediaWiki with MariaDB
#
# Access via "http://localhost:8080"
#   (or "http://$(docker-machine ip):8080" if using docker-machine)
version: '3'
services:
  mediawiki:
    image: mediawiki
    restart: always
    ports:
      - 8080:80
    links:
      - database
    volumes:
      - /var/www/html/images
      # After initial setup, download LocalSettings.php to the same directory as
      # this yaml and uncomment the following line and use compose to restart
      # the mediawiki service
      # - ./LocalSettings.php:/var/www/html/LocalSettings.php
  database:
    image: mariadb
    restart: always
    environment:
      # @see https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/DefaultSettings.php
      MYSQL_DATABASE: my_wiki
      MYSQL_USER: wikiuser
      MYSQL_PASSWORD: example
      MYSQL_RANDOM_ROOT_PASSWORD: 'yes'

After, I deployed the stack with the following command:

docker stack deploy -c stack.yml mediawiki

At the end I opened the configuration page of mediawiki (http://localhost:8080).
I put the following data

Database hos: localhost
database name: my_wiki
database username: wikiuser
database password: example

What I expected is that the configuration process recognizes the database, in this case mariaDb, but I tried with mysql and the situation is the same.
What I obtained is the following error message:

Cannot access the database: :real_connect(): (HY000/2002): No such file or directory. Check the host, username and password and try again. If using "localhost" as the database host, try using "127.0.0.1" instead (or vice versa).

Thanks
Angelo

Aklapper changed the task status from Stalled to Open.Jun 4 2020, 9:00 AM

Thanks! Copying a wild idea from https://stackoverflow.com/questions/57312109/mediawiki-docker-official-image-connection-refused-by-mysql :

Ugh. I got it to work by changing the Database host to simply database.

Aklapper renamed this task from problem connection mysql docker to Cannot access the database: :real_connect(): (HY000/2002): No such file or directory..Jun 4 2020, 9:00 AM

I tried with your solution and it works!!

dbarratt claimed this task.
Aklapper removed dbarratt as the assignee of this task.
Aklapper added a subscriber: dbarratt.

@dbarratt: Nothing has been resolved here, hence reopening. This task has a Documentation tag.

I also ran into this and the solution was the same: the hostname needs to be the name of the docker host when running with docker-compose. I'd submit a PR, but the error is on Docker Hub, and I don't see an obvious way to edit that.

Aklapper renamed this task from Cannot access the database: :real_connect(): (HY000/2002): No such file or directory. to Cannot access the database: :real_connect(): (HY000/2002): No such file or directory. (due to "Database host" entry being "localhost" instead of "database").Feb 14 2021, 2:23 PM

I also ran into this and the solution was the same: the hostname needs to be the name of the docker host when running with docker-compose. I'd submit a PR, but the error is on Docker Hub, and I don't see an obvious way to edit that.

The docs are located here:
https://github.com/docker-library/docs/tree/master/mediawiki