Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to my local docker Database Instance from Table Plus

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.

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:

I have tried any comibindation of wordpress and somewordpress in these fields: enter image description here

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

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

like image 311
David Jarrin Avatar asked Nov 29 '22 13:11

David Jarrin


1 Answers

There is another bit of information that should be added to the Praveen answer. If you have already mysql installed locally, on your computer/laptop, settings the db ports to:

- "3306:3306" 

it won't work because TablePlus will connect to your local mysql instance. Instead you should set your Docker mysql on a different published port and access that from TablePlus.

For example, set these ports on your Dockerfile (published port is 3356):

"3356:3306"

Then set the same port on TablePlus: enter image description here

like image 142
Sabre Avatar answered Dec 06 '22 04:12

Sabre