How to Connect to MariaDB from Terminal or GUI in PostgreSQL

Galaxy Glossary

How do I quickly connect to a MariaDB database from the terminal or a GUI client?

Use mysql CLI or GUI clients to open a secure session to a MariaDB server for running SQL.

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

What are the fastest ways to connect to MariaDB?

Use the mysql command-line client for scripts and quick checks, or a GUI like DBeaver, TablePlus, or Galaxy SQL Editor for visual work.

How do I connect from the terminal with a password?

Run mysql -u user -p -h host -P port dbname. When prompted, supply the password.Use --ssl-mode=REQUIRED in production.

Example

mysql -u shop_admin -p -h 192.168.1.10 -P 3306 ecommerce

How can I connect without exposing my password?

Create a ~/.my.cnf file with [client] section containing your credentials. Set file permission to 600; then run mysql ecommerce with no password prompt.

How do I connect through an SSH tunnel?

Create the tunnel: ssh -L 3307:db.internal:3306 user@bastion.Keep the terminal open, then connect locally with mysql -u shop_admin -p -h 127.0.0.1 -P 3307 ecommerce.

Which GUI clients work best?

DBeaver, TablePlus, and Galaxy provide native MariaDB drivers, SSL options, and query history. Configure host, port, user, password, database, and optionally SSH tunnel details.

How do I open a GUI connection in Galaxy?

Choose “Add Connection → MariaDB”, fill the host, port, user, and database, enable SSL if needed, and click “Test & Save”.Double-click the connection to start querying.

How do I run an initial test query?

After connecting, execute SELECT COUNT(*) AS total_orders FROM Orders; to verify access and row counts.

Can I auto-reconnect on network drops?

CLI: add --reconnect (older versions) or handle exit codes in a shell loop. GUI clients usually reconnect automatically; enable “auto-reconnect” in settings.

How do I switch databases once connected?

Inside mysql>, type USE analytics;.In GUIs, pick a different schema from the sidebar.

Best practices for secure connections?

Always require SSL, use least-privileged users, rotate passwords, and restrict host firewall rules. Store credentials in vaults or ~/.my.cnf with correct permissions.

Common use cases

Developers connect to fetch daily revenue, debug failed orders, or update product stock levels. Automated scripts use CLI with option files for nightly reports.

.

Why How to Connect to MariaDB from Terminal or GUI in PostgreSQL is important

How to Connect to MariaDB from Terminal or GUI in PostgreSQL Example Usage


-- List top-5 customers by spend after connecting
SELECT c.id, c.name, SUM(o.total_amount) AS total_spent
FROM Customers c
JOIN Orders o ON o.customer_id = c.id
GROUP BY c.id, c.name
ORDER BY total_spent DESC
LIMIT 5;

How to Connect to MariaDB from Terminal or GUI in PostgreSQL Syntax


mysql [--user=<user>] [--password[=<password>]] [--host=<host>] [--port=<port>] [--database=<dbname>] [--ssl-mode={DISABLED|PREFERRED|REQUIRED}] [--default-character-set=utf8mb4] [--execute="<SQL>"]

Example (ecommerce):
mysql --user=shop_admin --password=**** --host=db.prod --port=3306 --database=ecommerce --ssl-mode=REQUIRED --execute="SELECT customer_id, SUM(total_amount) AS lifetime_value FROM Orders GROUP BY customer_id;"

Common Mistakes

Frequently Asked Questions (FAQs)

Can I connect to MariaDB with psql?

No. psql is the PostgreSQL client. Use mysql or a MariaDB-aware GUI instead.

Why do I get “Host not allowed to connect”?

Your user lacks the correct host wildcard in the GRANT statement. Run GRANT ALL ON ecommerce.* TO 'shop_admin'@'10.%' IDENTIFIED BY '***';

How can I test SSL is active?

After connecting, run \s in the mysql shell and look for “SSL: Cipher in use”. GUI clients show SSL status in the connection info pane.

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.