Find the ip address running this command:
ip addr show docker0 | grep inetThis will be the PMA_HOST in below steps. The PMA_HOST of local machine is like this: 172.17.0.1
Now, run phppmyadmin on docker.
You can achieve this in two ways. Choose only one approach.
To connect local mysql from phpmyadmin on docker. Run this:
docker run --name phpmyadmin --rm -e PMA_HOST=172.17.0.1 -p 8080:80 phpmyadminRun phpmyadmin in arbitrary mode
docker run --name phpmyadmin --rm -e PMA_ARBITRARY=1 -p 8080:80 phpmyadminGo to localhost:8080 to login to phpmyadmin
Make sure the bind address of mysql is 0.0.0.0 and the MySQL user host is %. Add or update /etc/mysql/my.cnf of MySQL configuration.
[mysqld]
bind-address = 0.0.0.0Restart mysql
sudo systemctl restart mysqlAllow mysql user's host from everywhere:
UPDATE mysql.user SET Host='%' WHERE Host='localhost' AND User='username';
FLUSH PRIVILEGES;You can confirm it from MySQL query also:
SHOW GLOBAL VARIABLES LIKE 'bind_address';
SELECT user, host from mysql.user;If you have not installed docker or have permissions error running docker, follow these steps:
Install docker:
sudo snap install dockerCreate new group docker and add logged in user to there:
sudo groupadd docker
sudo usermod -aG docker $USERLog in as new group to confirm if you have sufficient permission:
newgrp dockerChange the docker.sock file permission:
sudo chown root:docker /var/run/docker.sock
For macOS, this also works: