Reputation: 2190
I'm trying to install/configure phpmyadmin using docker inside Ubuntu 14.04. I started like this:
docker run --name myadmin -d -e PMA_HOST=localhost -e PMA_PORT=3306 -p 8282:80 phpmyadmin/phpmyadmin
When I try to login I get the following error:
#2002 - Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2 "No such file or directory") — The server is not responding (or the local server's socket is not correctly configured).
mysqli_real_connect(): (HY000/2002): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2 "No such file or directory")
The MySQL server is installed directly in Ubuntu not in docker.
Any ideas?
Upvotes: 5
Views: 13284
Reputation: 111
I faced the same issue and none of the previous answers worked for me. I found the solution in the GitHub issue 271, which maps the local socket into the docker container:
docker run --rm --name pma-socket -p 8080:80 -e PMA_SOCKET=/run/mysqld/mysqld.sock -v /run/mysqld/mysqld.sock:/run/mysqld/mysqld.sock phpmyadmin:latest
Upvotes: 1
Reputation: 11
For mac OS users, use host.docker.internal as the host address which docker will resolve to the host's IP address.
docker run --rm --name myadmin -it -e PMA_HOST=host.docker.internal -e PMA_PORT=3306 -p 8282:80 phpmyadmin/phpmyadmin
Upvotes: 1
Reputation: 125
This is what worked for me:
"service mysql status" or "systemctl status mysqld"
(It should say active(running))
docker run --name="phpMyAdmin-local" -itd -e PMA_HOST=$(ip route show | grep docker0 | awk '{print $9}') -p 8283:80 phpmyadmin/phpmyadmin
docker ps -a
(check phpMyAdmin-local status is up)
Go to "localhost:8283" and check phpMyAdmin is there
Let your db receive external requests:
Edit file as sudo:
MariaDb: nano /etc/mysql/mariadb.conf.d/50-server.cnf
MySQL: nano /etc/mysql/my.cnf
(nano is the text editor and can be changed)
and change this line:
bind-address = 127.0.0.1
To this line: (note the "#")
# bind-address = 127.0.0.1
(ctrl+x to exit, "y" to save it and "enter" to confirm)
Modify users and login to mysql/mariadb cli with root privileges:
mysql -uroot -p -P3306
(enter password after running command)
Use mysql database to edit users:
use mysql;
Give pribvileges to specific user: (can be different from root if you have other users):
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
Then:
FLUSH PRIVILEGES;
and:
exit;
Restart mysql service:
service mysqld stop
service mysqld start
And now you would be able to login to phpMyAdmin with the user and password you specify in prev. commands and mysql/mariadb would accept connections.
Upvotes: 2
Reputation: 15
Instead of connecting through socket file try to connect using IP (127.0.0.1) and for PMA port use your machine IP which you can get through ifconfig command.
Upvotes: -2
Reputation: 485
You cannot use localhost in your docker container.
docker run --rm --name myadmin -it -e PMA_HOST=172.17.0.1 -e PMA_PORT=3306 -p 8282:80 phpmyadmin/phpmyadmin
Where 172.17.0.1 is my host ip of the docker0 bridge.
Upvotes: 8