I'm trying to run my website in a docker container. when I don't need a database everything works fine but while using a database I get Access denied for user 'test'@'localhost' (using password: YES). it happens even while I use root user. Here is my docker-compose.yml:
version: '3'
services:
php-apache-environment:
container_name: php-apache-wave
build:
context: ./php
dockerfile: Dockerfile
depends_on:
- db
volumes:
- ./php/src:/var/www/html/
ports:
- 8000:80
db:
container_name: db-wave
image: mysql
restart: always
volumes:
- ./db:/docker-entrypoint-initdb.d
environment:
MYSQL_ROOT_PASSWORD: test
MYSQL_DATABASE: test
MYSQL_USER: test
MYSQL_PASSWORD: test
ports:
- "9906:3306"
and here is how I connect to db in my php file:
$conn = new mysqli("db-wave","test","test","test");
What is the problem?! everything works fine while I use xampp or other web servers. But in docker, the error persists.
Aucun commentaire:
Enregistrer un commentaire