Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

NielsNumbers's avatar

How to setup MySQL Connection on Ubuntu (so I can use Docker)?

I want to use DOCKER for my local development.

I found this guest-spotlight video which seems to be exactly for this usecase: https://laracasts.com/series/guest-spotlight/episodes/2

However, at min 04:00 he is using a commercial software called TablePlus to create a new MYSQL Connection. I have "mysql" installed, but I don't know how to setup a connection with docker.

Until now, I used Laravel Homestead and PHPMyAdmin to manage my tables.

Does anyone know how to setup a MySql Connection in Ubuntu without using TablePlus?

0 likes
6 replies
bugsysha's avatar

From your question I'm not sure if you want to create a connection from your Laravel app or from the MySQL client app?

mkshingrakhiya's avatar

If this is your Docker configuration for MySQL service...

mysql:
    container_name: mysql
    image: mysql:8
    command: --default-authentication-plugin=mysql_native_password
    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: db_name
      MYSQL_USER: db_user
      MYSQL_PASSWORD: db_password
    restart: unless-stopped
    tty: true
    ports:
      - "3406:3306"
    volumes:
      - ./mysql:/var/lib/mysql
    networks:
      - default

Then below would be the correct configuration for your MySQL client.

Host: 127.0.0.1
Username: db_user
Password: db_password
Database: db_name
Port: 3406
NielsNumbers's avatar

@bugsysha I would like to connect to the MySQL app that I have just booted with docker. So that I can create databases etc. Either by terminal, or through PhpMyAdmin

NielsNumbers's avatar

@mkshingrakhiya Okay that would be what I have to put in my .env file, right? But how can I connect to MySql that booted from docker? Either by terminal, or through PhpMyAdmin

Please or to participate in this conversation.