在Docker中使用Mysql的Sequel Pro [英] Sequel Pro with Mysql in Docker

查看:490
本文介绍了在Docker中使用Mysql的Sequel Pro的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用docker-compose构建了2个docker容器.我在Mac上使用Docker,没有boot2docker.

I build 2 docker container with docker-compose. I use Docker on Mac, no boot2docker.

version: '2'
    services:
        drupal-web:
            image: drupal:latest
        ports:
            - "8080:80"
    depends_on:
            - mysql-server
    links:
            - mysql-server:mysql
    mysql-server:
        image: mysql
    environment:
        MYSQL_DATABASE: drupal
        MYSQL_ROOT_PASSWORD: root
        MYSQL_USER: drupal
        MYSQL_PASSWORD: drupal

一切正常.我成功安装了Drupal.

Everything works fine. I install Drupal successfully.

问题是:我想将SequelPro连接到我的数据库,但是我没有连接到mysql容器. 我是Docker初学者.

The problem is: I would like to connect SequelPro to my DB, but i dont get a connection to the mysql container. I'm a docker beginner.

推荐答案

您忘记向主机公开数据库端口,因此只需添加

You forgot to expose your DB port to the host, so simply add

mysql-server:
    image: mysql
    ports: 
      - "3306:3306"
    environment:
        MYSQL_ROOT_PASSWORD: root
        MYSQL_DATABASE: drupal
        MYSQL_USER: drupal
        MYSQL_PASSWORD: drupal

然后使用以下命令连接到Sequel Pro中的数据库:

And then connect to the database in Sequel Pro using:

user: root
password: root
host: localhost
port: 3306

如果您已经在主机上运行了本地mysql数据库,请更改端口

If you already have a local mysql database running on your host, change the port

ports: 
  - "4306:3306"

,然后连接到端口4306而不是3306.请注意,在Drupal容器中,您仍将使用3306

and then connect to port 4306 instead of 3306. Be aware, from the Drupal container, you will still use 3306

这篇关于在Docker中使用Mysql的Sequel Pro的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆