Docker Community Forums

Share and learn in the Docker community.

Trouble Connecting Piwigo with MariaDB [Solved]

Here’s what I’m trying to do: I’m trying to deploy a Piwigo server in docker which connects to MariaDB which is also a container.
This is what I used for running MariaDB (Piwigo does not support MySQL 8, and I couldn’t get mysql working so I used the mysql 5 equivelent in mariadb)

docker run -d 
    --name mariadb-10.2 
    -p 3306:3306 
    -e MYSQL_ROOT_PASSWORD=not_my_actual_password
    -v "C:\\Docker\Database:/var/lib/mysql" 
    -e TZ=America/Denver 
   --restart unless-stopped 
   mariadb:10.2

To containerize piwigo, I used

docker run -d 
   --name=piwigo 
   -e PUID=1000 
   -e PGID=1000 
   -e TZ=America/Denver 
   -p 8282:80 -v "C:\Docker\Piwigo\Config:/config" 
   --link mariadb-10.2 
   --restart unless-stopped 
   linuxserver/piwigo

When I try to setup the database connection in piwigo using (Host: mariadb-10.2, User: piwigo, Password: not_my_actual_password, Database Name: piwigo) I get this error

2020/06/01 07:10:03 [error] 318#318: *22 FastCGI sent in stderr: "PHP message: PHP Warning:  mysqli::__construct(): (HY000/1045): Access denied for user 'piwigo'@'172.17.0.1' (using password: YES) in /config/www/gallery/include/dblayer/functions_mysqli.inc.php on line 52PHP message: PHP Warning:  mysqli::set_charset(): Couldn't fetch mysqli in /config/www/gallery/include/dblayer/functions_mysqli.inc.php on line 88" while reading response header from upstream, client: 172.17.0.1, server: _, request: "POST /install.php?language=en_US HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8282", referrer: "http://localhost:8282/install.php?language=en_US"

Note: The database piwigo exists, the user piwigo has full access to the entire server (not just it’s database, which will change in the future), and the password is correct.
I have also tried changing the host field in piwigo to the IP address of the host, the IP address of the mariaDB container, and have tried appending a port number, but nothing seems to work.

SOLUTION FOUND

After looking into it more, I noticed that according to the mariadb logs, the user piwigo@ipaddress did not have permission. When I created the user, I used

GRANT ALL ON piwigo.* to 'piwigo'@'localhost' IDENTIFIED BY 'not_my_actual_password' WITH GRANT OPTION;

When connecting from piwigo, the ip address is not ‘localhost’ so the authentication fails. To fix this, I just granted the user the ability to connect from any ip address, replacing ‘localhost’ with ‘%’.

GRANT ALL ON piwigo.* to 'piwigo'@'%' IDENTIFIED BY 'not_my_actual_password' WITH GRANT OPTION;