Access to mysql container from other container

前端 未结 3 1739
执笔经年
执笔经年 2020-12-15 18:29

I have setup docker container with mysql that expose 3306. I\'ve specified database user, database password and create a test db and give the privileges to new user.
In

3条回答
  •  死守一世寂寞
    2020-12-15 18:43

    In your docker-compose.yml file add a link property to your webserver service: https://docs.docker.com/compose/networking/#links

    Then in your query string, the host parameter's value is your database service name:

    $mysqli = new mysqli("database", "mattia", "prova", "prova");
    

提交回复
热议问题