简体   繁体   English

通过Sequel Pro mac连接docker mysql

[英]Connect to docker mysql through Sequel Pro mac

I'm trying to connect to my running Docker SQL database on my machine through Sequel Pro, unfortunately appears that connecting to it is failing/isn't possible through this method?我正在尝试通过 Sequel Pro 连接到我机器上正在运行的 Docker SQL 数据库,不幸的是似乎连接失败/无法通过此方法连接?

My docker-compose.yml file is:我的docker-compose.yml文件是:

version: "3.7"
services:
  app:
    build:
      args:
        user: user
        uid: 1000
      context: ./
      dockerfile: Dockerfile
    image: brand
    container_name: brand-app
    restart: unless-stopped
    working_dir: /var/www/
    volumes:
      - ./:/var/www
    networks:
      - brand

  db:
    image: mysql:5.7
    container_name: brand-db
    restart: unless-stopped
    ports:
      - 3306:3306
    environment:
      MYSQL_DATABASE: ${DB_DATABASE}
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
      MYSQL_PASSWORD: ${DB_PASSWORD}
      MYSQL_USER: ${DB_USERNAME}
      SERVICE_TAGS: dev
      SERVICE_NAME: mysql
    volumes:
      - ./docker-compose/mysql:/docker-entrypoint-initdb.d
    networks:
      - brand

  nginx:
    image: nginx:alpine
    container_name: brand-nginx
    restart: unless-stopped
    ports:
      - 8000:80
    volumes:
      - ./:/var/www
      - ./docker-compose/nginx:/etc/nginx/conf.d/
    networks:
      - brand

networks:
  brand:
    driver: bridge

And I'm trying to connect using:我正在尝试使用以下方式进行连接:

127.0.0.1 root root port 3306 127.0.0.1 root根端口3306

which appears to fail... not sure how to connect这似乎失败了......不知道如何连接

I've got docker-compose up running, and my containers are all running我已经运行了docker-compose up ,我的容器都在运行

I encounter this question too.我也遇到这个问题。 the why of dealing with this problem is to change your database_host to the name you had given in docker-compose.yml处理这个问题的原因是将您的 database_host 更改为您在docker-compose.yml给出的名称

for example:例如:

this.connection = mysql.createConnection({
    host: 'db' || '127.0.0.1',
    user: 'root',
    password: '123',
    database: 'CHIRINOS',
    port: 3306
});

here db in host is your database name of docker container这里db in host 是你的 docker 容器的数据库名称

This solution fixed the issue for me.这个解决方案为我解决了这个问题。

Looks like Sail uses MySQL 8 by default, which means that you won't be able to use Sequel Pro with Sail.看起来 Sail 默认使用 MySQL 8,这意味着您将无法将 Sequel Pro 与 Sail 一起使用。 You can try using nightly builds or try Sequel Ace - Sequel Pro's fork.您可以尝试使用夜间构建或尝试 Sequel Ace - Sequel Pro 的分支。

This is the source of the solution 这是解决方案的来源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM