Search code examples
mysqldockervisual-studio-codedocker-compose

How to connect from VSCode to a mysql docker container?


I'm just testing the VSCode MSSQL extension, I have a simple MySQL server running on docker out of this docker-compose file.

services:
  sql-server-db:
    container_name: testDB
    image: mysql
    ports: 
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: admin
      ACCEPT_EULA: "Y"

I can connect from the CLI, I can connect from the windows SQL Workbench but I cannot connect from the VSCode extension.

Error: [9:42:32 PM] Connecting to server "localhost,3306" on document "localhost,3306__root_undefined". [9:42:32 PM] Error connecting to server "localhost,3306". Details: Internal connection fatal error.

any ideas?


Solution

  • I guess you should use sql-server-db except localhost as hostname in VScode SQL connection.