Docker Community Forums

Share and learn in the Docker community.

"Cannot access the database: No such file or directory (localhost:3306)" error during "Connect to database" installation Mediawiki step


#1

Hello,
Could you advise what could be the error.

I faced with “Cannot access the database: No such file or directory (localhost:3306)” error during “Connect to database” mediawiki installtion step. I am truing install Mediawiki on Windows and downloaded Mediawiki image with command: docker pull mediawiki.

I run new container with command like bellow

docker run --name <new_container_name> -e MYSQL_ROOT_PASSWORD=mysecretpassword –p 8080:80 -d <image_name>

Run new mediawiki container with command like bellow

docker run --link mysql:db -p 80:80 -p 443:443 -d simplyintricate/mediawiki

I receive “Cannot access the database: No such file or directory (localhost)” error message when I specify MySql credentials during “Connect to database” step.

I checked next images bellow from Docker hub:

  • mediawiki (1.31) - “Cannot access…” error
  • simplyintricate/mediawiki (1.29 ver) - “Cannot access…” error
  • wikimedia/mediawiki – mediawiki is not available at all (http://localhost)

synctree/mediawiki – mediawiki is not available at all (http://localhost), and I couldnot enter to mediawiki container (docker exec –it mediawiki_ synctree bash).

MySql 3306 port is available in PowerShell:

PS C:\Users\mpav> TNC -ComputerName localhost -Port 3306

ComputerName : localhost

RemoteAddress : ::1

RemotePort : 3306

InterfaceAlias : Loopback Pseudo-Interface 1

SourceAddress : ::1

TcpTestSucceeded : True

I tried link Mediawiki container to MySql container, but this did not help.

I installed MySql server on my PC. TNC command in PowerShell returns success, but Mediawiki installations reruns the same “Cannot access…” error.

Also I tried to use different ip address for access to MySql, but TNC command returns error for all ip adrees, and Mediawiki installation still returns “Cannot access…” error. TNC is success only for localhost -Port 3306.

Thank you in advance.


(Martin Terp) #2

Hi :slight_smile:

Instead of using “localhost” when defining the database host, try using the IP of the host.


#3

Hello, Martin.

I created new containers bellow, and allow the user within MySQL to connect from the IP of my host machine. I tested ip 0.0.0.0 and 127.0.0.1 but I receive the same error.
Also for “but what if” I tested several ip bellow.

  1. MySql.
  2. Mediawiki

docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d0fc15fdee32 simplyintricate/mediawiki “/bin/sh -c /bin/sta…” 8 days ago Up About an hour 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp mediawiki-simplyintricate
ee991977212e mysql/mysql-server “/entrypoint.sh mysq…” 8 days ago Up About an hour (healthy) 0.0.0.0:3306->3306/tcp, 33060/tcp mysqlwiki

(Database name:“my_wiki”, Database username:“monty”, Database password:“some_pass” are valid parameters. I can login in mysql with Database username:“monty”, Database password:“some_pass” “C:\Users\mpav>docker exec -it mysqlwiki mysql -u monty -h 127.0.0.1 -p”).


Database host: 0.0.0.0:3306 - “Cannot access the database: Connection refused (0.0.0.0:3306).”

Database host: 0.0.0.0 - “Cannot access the database: Connection refused (0.0.0.0)”.

Database host: 127.0.0.1 - “Cannot access the database: Connection refused (127.0.0.1)”

  1. Also I checked my Mediawiki container with “docker inspect mediawiki-simplyintricate” and tried to use “Database host:” ip:
    172.17.0.1
    Cannot access the database: Server sent charset unknown to the client. Please, report to the developers (172.17.0.1).

172.17.0.2
Database host: 172.17.0.2 - “Cannot access the database: Server sent charset unknown to the client. Please, report to the developers (172.17.0.2).”

  1. I found DockerNAT ip 10.0.75.1 when I executed command “Get-NetIPAddress” in PowerShell and tested this ip too:
    Database host: 10.0.75.1:3306 - " Cannot access the database: Connection timed out (10.0.75.1:3306)"

Database host: 10.0.75.1 - “Cannot access the database: Connection timed out (10.0.75.1)”

  1. I also tested two ip bellow for “but what if”:

Database host: 10.98.1.71 - “Cannot access the database: Server sent charset unknown to the client. Please, report to the developers (10.98.1.71)”

Database host: 172.20.176.1 - “Cannot access the database: Server sent charset unknown to the client. Please, report to the developers (172.20.176.1)”

Thank you in advance.


(Martin Terp) #4

It seems like the ips with the errors " Cannot access the database: Server sent charset unknown to the client. Please, report to the developers" actually hits a database.

can you try and add/edit these settings to your mysql my.cnf:

[mysqld]
character-set-server = utf8
collation-server = utf8_unicode_ci

restart the db and try again?


#5

Hello Martin,

I added this two string in my.cnf and tried to test mysql with telnet(please see bellow). Wiki still can not connect to mysql server.

telnet 127.0.0.1 3306

J
Z6sSLJ3A nZa
N.;)LARcaching_sha2_password!#08S01Got packets out of order

Connection to host lost.

Wiki returns the error

Database host: 127.0.0.1 - " Cannot access the database: Connection refused (127.0.0.1)."
Cannot access the database: Connection refused (127.0.0.1).

I can login in MySql:

C:\Users\mpav>docker exec -it mysqlwiki mysql -u root -h 127.0.0.1 -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.13 MySQL Community Server - GPL

Copyright © 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql>

Could you please advice if this problem can be ralated to Windows?

  1. I try setup Mediawiki on Windows.
  2. I try to use Mysql from docker image on the same PC (I tried several images).
  3. I try to setup MySql server “as usual” on PC (without Docker).

All warians MySql server returns the same ansver in “telnet”. And Mediawiki can not connect to MySql in all this cases.
Command like “mysql -u root -h 127.0.0.1 -p” works fine in all variants MySql(several docker images and “as usual” MySql server).

Thank you in advance.


#6

Martin,

Just to clarify,

I can connect from MySql client- Workbench to mysql when MySql56-server is sarted (not Docker). But I can not to connect to MySql started from docker(when MySql56 server is stopped) from MySql client - Workbench.

Thank you!


(Igor Kyslyi) #7

Hi folks,
I am experiencing exactly the same issue.
Does anybody know how to solve it?