从 Table Plus 连接到我的本地 docker 数据库实例 [英] Connecting to my local docker Database Instance from Table Plus

查看:42
本文介绍了从 Table Plus 连接到我的本地 docker 数据库实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个本地 docker wordpress 实例,我正在尝试使用 SQL 客户端(在我的例子中是 TablePlus)连接到数据库,但我遇到了问题.

I have created a local docker wordpress instance and I am trying to connect to the database with a SQL Client (in my case TablePlus) but I am having trouble.

我从此处显示的 docker-compose.yml 文件创建了 docker 容器:

I created the docker containers from a docker-compose.yml file shown here:

version: '3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8028:80"
       - "8029:8029"

     volumes:
       - ./themes/travelmatic:/var/www/html/wp-content/themes/yadayada


     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       VIRTUAL_HOST: leasepilot.local

volumes:
    db_data:

我在这些领域尝试过 wordpress 和 somewordpress 的任何组合:

I have tried any comibindation of wordpress and somewordpress in these fields:

我也可以选择通过 SSH 连接,但我觉得不需要这样做?

I also have the option to connect over SSH but I don't feel I would need to do that?

1) 调试此类问题的最佳方法是什么?2)信用证是什么?哈哈

1) What is the best way to debug this type of issue? 2) What are the creds? lol

推荐答案

正如 David 在他的评论中所建议的,您需要在 docker-compose.yml 中添加端口映射.所以,你修改后的 docker-compose.yml 应该是这样的:

Just as David has suggested in his comment, you need to add port mapping in docker-compose.yml. So, your modified docker-compose.yml would be something like this:

version: '3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress
     ports:
       - "3306:3306"   
   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8028:80"
       - "8029:8029"

     volumes:
       - ./themes/travelmatic:/var/www/html/wp-content/themes/yadayada


     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       VIRTUAL_HOST: leasepilot.local

volumes:
    db_data:

并且您已经在环境变量中的 docker-compose.yml 中提供了凭据.

And you have already provided the creds in the docker-compose.yml in environment variables.

这篇关于从 Table Plus 连接到我的本地 docker 数据库实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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