Use the SQLTools extension or MySQL Shell for VS Code to open, query, and manage MySQL databases directly from Visual Studio Code.
Keeping code and data in one editor speeds up debugging, simplifies sharing, and lets you use VS Code shortcuts, Git integration, and Galaxy’s AI copilot while working on SQL.
Search the VS Code marketplace for SQLTools (most popular) or MySQL Shell for VS Code. Click Install and reload the window.
Open the Command Palette (⇧⌘P / Ctrl+Shift+P) → SQLTools: Add New Connection. Select MySQL, then fill in the form or paste a URL. Save to settings.json
to reuse later.
Add a block like:{ "sqltools.connections": [ { "driver": "MySQL", "name": "LocalShop", "server": "127.0.0.1", "port": 3306, "database": "ecommerce", "username": "dev", "password": "secret", "connectionTimeout": 30, "previewLimit": 50 } ]}
Use a one-line URL:mysql://dev:secret@127.0.0.1:3306/ecommerce?ssl=false
. SQLTools parses the string and stores the details automatically.
Press ⌘E/Ctrl+E to open the connection explorer, double-click LocalShop, then write SQL in a .sql
file and hit ⌘Enter/Ctrl+Enter. Results appear in a grid below your code.
Create extra connection blocks, group them in folders, and assign colors. SQLTools lets you switch contexts without editing code, perfect for staging vs. production.
Store passwords in VS Code’s Secret Storage, enable SSL with ?ssl=true
, and grant the DB user read-only rights. Commit settings.json
to Git without credentials by using environment variables.
Yes. Set sshHost
, sshUser
, and sshPort
fields in your connection block, or append ?ssh=true
in the URL to open the database only through the tunnel.
Galaxy integrates through the extension marketplace. Once installed, it suggests queries, explains errors, and refactors SQL directly in your VS Code editor.
After running the query, click the download icon in the results pane or execute SQLTools: Save Results as CSV from the Command Palette.