I am new to docker and container world. Having trouble setting up mysql client on my local machine. I am referring to this tutorial.
My docker-compose.yml file looks like
version: "3.7"
services:
db:
image: mysql
container_name: "mySql-wordpress"
restart: always
environment:
MYSQL_ROOT_PASSWORD: p@55w0rD@1234
ports:
- "3306:3306"
command: --default-authentication-plugin=mysql_native_password
networks:
- back
adminer:
image: adminer
restart: always
ports:
- 8282:8080
networks:
back:
volumes:
db_data:
No issue with that I was able to execute docker-compose up -d
command successfully. Below is out put of docker ps
command
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
NAMES
8ecd82867a06 mysql "docker-entrypoint.s…" 37 seconds ago Up 34 seconds 0.0.0.0:3306->3306/tcp, 33060/tcp
mySql-wordpress
ae01696e6445 adminer "entrypoint.sh docke…" 8 minutes ago Up 7 seconds 0.0.0.0:8282->8080/tcp
ae01696e6445_wordpressdemo_adminer_1
aa7e1055fc99 phpmyadmin/phpmyadmin "/docker-entrypoint.…" 16 minutes ago Up 16 minutes 0.0.0.0:8181->80/tcp
wordpressdemo_phpmyadmin_1
Now when I try to login into Adminer portal
I am getting error message
SQLSTATE[HY000] [2002] No such file or directory
I also tried to install phpmyadmin/phpmyadmin
Image but getting below error:
mysqli_real_connect(): The server requested authentication method unknown to the client [caching_sha2_password]
mysqli_real_connect(): (HY000/2054): The server requested authentication method unknown to the client
It looks like my SQL server is not setup properly. Any pointers?
UPDATE 1
With the image mysql:5.7
I can see below two error messages on phpMyAdmin
mysqli_real_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known
mysqli_real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known
3
Answers
I’m not familiar with docker, but I had this same No such file or directory error with adminer when I tried to login.
I fixed it by creating a custom php.ini file to tell PHP where MYSQL put its socket file. I had compiled PHP manually so I did not already have a php.ini. Check if you already have one.
In my case under Debian Linux, I found the socket file here /var/run/mysqld/mysqld.sock
So inside the php.ini file, added this:
mysqli.default_socket = "/var/run/mysqld/mysqld.sock"
Restart your PHP service.
If you use docker and, like in your example, your database docker-container is called
db
then enter this asServer
in the form:In the docker-compose file in the Adminder service add lines
ADMINER_DEFAULT_SERVER must be the same name as the service name for your database. In your case, it is ‘db’
When you go to localhost:8282, then Adminder should pull the server name automatically.