Home > Back-end >  How to connect Sequel Pro (on a Mac) to a MySQL in a Docker
How to connect Sequel Pro (on a Mac) to a MySQL in a Docker

Time:10-03

At my new job I was given a Mac (Mac Mini M1 with Big Sur), whereas I've used Windows and some Linux my whole life. First week yet.

I have a working Docker container with mysql-server and also PhpMySql.

Nevertheless I wanted to use Sequel Pro locally to connect to Mysql and I'm failing completely. Screenshot of error: "Connection failed! Unable to connect to host 127.0.0.1, or the request timed out."

I've installed mysql-client with Homebrew and I'm able to connect with docker's mysql without any problem using:

mysql -h 127.0.0.1 -u sail -p

My .env file is as follows:

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laravel8vue
DB_USERNAME=sail
DB_PASSWORD=password

My docker-compose.yml (version 3) related to mysql is as follows:

mysql:
    image: 'mysql/mysql-server:8.0.26'
    ports:
        - '${FORWARD_DB_PORT:-3306}:3306'
    environment:
        MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
        MYSQL_DATABASE: '${DB_DATABASE}'
        MYSQL_USER: '${DB_USERNAME}'
        MYSQL_PASSWORD: '${DB_PASSWORD}'
        MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
    volumes:
        - 'sailmysql:/var/lib/mysql'
    restart: unless-stopped
    networks:
        - sail
    healthcheck:
        test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"]
        retries: 3
        timeout: 5s

My Sequel Pro using the standard tab with the following settings (screenshot):

Host: 127.0.0.1 Username: sail Password: password Database: laravel8vue Port: 3306

How is it possible that I can connect with mysql-client but not with Sequel Pro? What am I missing?

Thank you for your time!

CodePudding user response:

You have to expose the db port to the host. If you already running a mysql server in your device and try to running a mysql in docker means you have to changed the port number in docker-compose.

port:
 - 3307:3306 

in Sequel Pro, you configuration should be like this.

UserName: user
Host: Your system IP / localhost / 
DBPassword: password
port: 3307 

CodePudding user response:

Gave up on Sequel Pro.

Tried with Sequel Ace, which graphically is basically the same, and it worked straight away!

  • Related