Search code examples
dockerserverphpmyadminremote-server

docker phpmyadmin - how to add remote server


I can't seem to find the real installation path of my phpmyadmin.

I bash into the phpmyadmin container like this: (I'm on windows)

winpty docker exec -it pma_container_name sh

And then I got in by default in /var/www/html

and I see all the phpmyadmin files there.

I also noticed that there's also a phpmyadmin in /etc/phpmyadmin containing 3 config files, config.inc.php, congif.secret.inc.php, config.user.inc.php

There's also a phpmyadmin in the /usr/src/phpmyadmin containing all the phpmyadmin files.

Now, In /var/www/html - I just:

cp config.sample.inc.php config.inc.php

Then I created a sample file like:

touch phpinfo.php

and I access it in the browser on localhost:8082/phpmyadmin.php

and it totally works.

Now, since I know initially that it was reading my new file, added some config at the bottom:

$i++;
$cfg['Servers'][$i]['host'] = ''; // remote ip address here
$cfg['Servers'][$i]['user'] = '';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['auth_type'] = 'cookie';

but still nothing happened in the phpmyadmin.

I can't seem to add or choose a remote server.

Any idea why?

I also noticed that the container is in Alpine.


Solution

  • When you run the container set the PMA_HOST environment variable with the host name of your MySQL server. You can also use PMA_USER and PMA_PASSWORD. For example:

    docker run --name myadmin -d -e PMA_HOST=mydatabase.com -e PMA_USER=admin -e PMA_PASSWORD=password -p 8080:80 phpmyadmin/phpmyadmin
    

    If you want a custom configuration file, use:

    -v /some/local/directory/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php
    

    For more information see the Docker image description:

    https://hub.docker.com/r/phpmyadmin/phpmyadmin/