简体   繁体   中英

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. [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?

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

Had pretty much the same problem, try another extension: https://github.com/cweijan/vscode-database-client

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM