How to Connect MariaDB to VS Code in PostgreSQL

Galaxy Glossary

How do I connect MariaDB to VS Code?

Opens a direct SQL session from Visual Studio Code to a MariaDB server so you can write, run, and debug queries inside the editor.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Description

Table of Contents

Why connect MariaDB to VS Code?

Running queries inside VS Code removes context-switching, lets you save scripts in Git, and enables Galaxy AI copilot to refactor SQL instantly.

Which VS Code extension should I install?

Install SQLTools plus the SQLTools MariaDB/MySQL Driver. Both are free in the Marketplace and support connection pooling, snippets, and result grids.

How do I install the extension?

Open the Extensions panel ⇧⌘X, search for “SQLTools”, click Install, then repeat for “SQLTools MariaDB/MySQL”. Reload VS Code when prompted.

How do I create a new MariaDB connection?

Press ⌘P → type SQLTools: Add New Connection → choose MariaDB/MySQL. Fill in host, port, user, password, and default database. Save to settings.json so it syncs with source control.

Connection string format

Use the URI shown below or individual fields in the wizard.

mariadb://shop_admin:Secr3t@db.example.com:3306/shop?ssl=true&connectionTimeout=10000

How do I run queries against ecommerce tables?

Open a .sql file, select a connection from the Status Bar, write your query, and hit ⌘-Enter. Results appear in the Results View and can be exported as CSV.

What best practices improve reliability?

Store secrets in .env and reference them with VS Code variables, enable ssl=true for production, and commit the settings.json minus passwords.

How to fix common connection errors?

"ER_ACCESS_DENIED_ERROR" means wrong credentials—double-check the user has SELECT on the target schema. "Handshake inactivity timeout" indicates a blocked port; ensure 3306 is open.

Why How to Connect MariaDB to VS Code in PostgreSQL is important

How to Connect MariaDB to VS Code in PostgreSQL Example Usage


SELECT  c.id,
        c.name,
        SUM(oi.quantity * p.price) AS lifetime_value
FROM    Customers  c
JOIN    Orders     o  ON o.customer_id = c.id
JOIN    OrderItems oi ON oi.order_id   = o.id
JOIN    Products   p  ON p.id          = oi.product_id
GROUP BY c.id, c.name
ORDER  BY lifetime_value DESC
LIMIT   10;

How to Connect MariaDB to VS Code in PostgreSQL Syntax


mariadb://[user[:password]@]host[:port]/database[?param=value]

Parameters:
  user                Database user, e.g., shop_admin
  password            Matching password
  host                IP or DNS (default 127.0.0.1)
  port                3306 unless changed
  database            Default database opened in VS Code
  ssl                 true | false (recommended true in prod)
  connectionTimeout   Milliseconds before aborting

Example:
  mariadb://shop_admin:Secr3t@db.example.com:3306/shop?ssl=true&connectionTimeout=10000

Common Mistakes

Frequently Asked Questions (FAQs)

Can I store multiple connections?

Yes. SQLTools saves each connection as a separate object in settings.json. Switch between them from the Status Bar.

Does Galaxy AI copilot work inside VS Code?

Absolutely. With the connection active, Galaxy suggests context-aware completions, refactors queries, and explains execution plans.

How do I run a single statement in a file?

Select the text you want to execute and press ⌘-Enter; SQLTools sends only the highlighted portion to MariaDB.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.