Docker Community Forums

Share and learn in the Docker community.

Unable to connect with Piwigo Docker install

Hi All,

Currently in the process of installing Piwigo on Docker with MySQL. I’m not new to MySQL or Piwigo however I am to Docker.

My basic steps are as follows and they seem to work fine.

Install of MySQL DB

docker run -d -p 3306:3306 --name piwigo_db \
-e MYSQL_ROOT_PASSWORD=piwigo \
-e MYSQL_DATABASE=piwigo_db \
-e MYSQL_USER=piwigo \
-e MYSQL_PASSWORD=piwigo \
-v /data/var/lib/mysql \
mysql

And then Install of Piwigo

docker create \
  --name=piwigo_web \
  -e PUID=1000 \
  -e PGID=1000 \
  -p 80:80 \
  -v /data/config:/config \
  --restart unless-stopped \
  linuxserver/piwigo

When I navigate to the Piwigo installer I get “Cannot connect to server” error.

If I look in the logs I can see php doesn’t seem to be able to connect to the Database

2019/04/22 00:45:52 [error] 291#291: *25 FastCGI sent in stderr: "PHP message: PHP Warning:  mysqli::__construct(): The server requested authentication method unknown to the client [caching_sha2_password] in /config/www/gallery/include/dblayer/functions_mysqli.inc.php on line 67
PHP message: PHP Warning:  mysqli::__construct(): (HY000/2054): The server requested authentication method unknown to the client in /config/www/gallery/include/dblayer/functions_mysqli.inc.php on line 67
PHP message: PHP Warning:  mysqli::set_charset(): Couldn't fetch mysqli in /config/www/gallery/include/dblayer/functions_mysqli.inc.php on line 103" while reading response header from upstream, client: 1.125.110.170, server: _, request: "POST /install.php?language=en_GB HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "my.host.org", referrer: "http://my.host.org/install.php?language=en_GB"
2019/04/22 00:49:17 [error] 291#291: *31 FastCGI sent in stderr: "PHP message: PHP Warning:  mysqli::__construct(): The server requested authentication method unknown to the client [caching_sha2_password] in /config/www/gallery/include/dblayer/functions_mysqli.inc.php on line 67
PHP message: PHP Warning:  mysqli::__construct(): (HY000/2054): The server requested authentication method unknown to the client in /config/www/gallery/include/dblayer/functions_mysqli.inc.php on line 67
PHP message: PHP Warning:  mysqli::set_charset(): Couldn't fetch mysqli in /config/www/gallery/include/dblayer/functions_mysqli.inc.php on line 103" while reading response header from upstream, client: 1.125.110.170, server: _, request: "POST /install.php?language=en_GB HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "my.host.org", referrer: "http://my.host.org/install.php?language=en_GB"

I can connect via command line successfully

$ mysql -u piwigo -h 172.31.9.172 -p

root@ip-172-31-9-172:/data/config/log/nginx# mysql -u piwigo -h 172.31.9.172 -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 8.0.15 MySQL Community Server - GPL

Copyright (c) 2000, 2019, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| piwigo_db          |
+--------------------+
2 rows in set (0.00 sec)

mysql>

Hi :slight_smile:

You should create a shared network for the 2 containers.

docker network create piwigo

docker run -d -p 3306:3306 --network piwigo --name piwigo_db
-e MYSQL_ROOT_PASSWORD=piwigo
-e MYSQL_DATABASE=piwigo_db
-e MYSQL_USER=piwigo
-e MYSQL_PASSWORD=piwigo
-v /data/var/lib/mysql
mysql

docker run -d --network piwigo
–name=piwigo_web
-e PUID=1000
-e PGID=1000
-p 80:80
-v /data/config:/config
–restart unless-stopped
linuxserver/piwigo

Then you should be able to connect from web to db, by using piwigo_db as hostname

But when you need to bundle containers like this, i advice you to take a look at:

:slight_smile:

1 Like

For me it worked changing the password encryption for the sql user from Cashing SHA2 authentication to Native MySQL-Authentication.