AD JB Toolbox 01 EN

MariaDB Tutorial / Troubleshoot Local and Remote MariaDB Connections

Narrow a MariaDB connection problem by checking server reachability, address and protocol, account matching, authentication and database permissions in order. Remote access additionally needs an appropriate listener, network policy, account host and verified encryption; first establish a known local TCP connection.

Separate the client, server and network path

An installed client is not proof of a running server. An ODBC driver alone may provide neither a server nor a command-line client. Check the actual package, service name and executable paths using the Windows installation guide or Ubuntu installation guide. Check installation/service state through Install MariaDB on Windows and Start the Server or Install MariaDB on Ubuntu and Start the Server, then separately verify allowed operations using Create Users and Grant Only Required Privileges.

Symptom Check first Avoid confusing it with
Command not found Client executable and PATH A database password failure
Refused or timed out Server, address, port and path Something GRANT alone can fix
Access denied User, host and authentication method Necessarily only a wrong password
Unknown database Actual server and database name A table problem
TLS verification error Hostname, CA and certificate A reason to routinely disable verification

Check the MariaDB documentation for the syntax and conditions used here: mariadb command line client, mariadb remote connection guide.

Fix the local connection path explicitly

This command assumes the client and server are on the same PC and the server listens on port 3306. Replace that port if the actual configuration differs; supply the password only at its prompt.

mariadb --protocol=tcp --host=127.0.0.1 --port=3306 --user=course_user --password --default-character-set=utf8mb4 shopcourse
SELECT VERSION(),@@hostname,@@port,DATABASE();
SELECT USER(),CURRENT_USER();
SHOW GRANTS;

Confirm the version, host, port, selected database and CURRENT_USER(). Depending on the platform and options, localhost can imply a socket, named pipe or TCP. This exercise explicitly chooses TCP and 127.0.0.1 to remove that ambiguity.

Test real database access after authenticating

Check that products_44_lab is unused, then create the full independent fixture with the appropriate learning account:

USE shopcourse;
CREATE TABLE products_44_lab (
  product_id INT NOT NULL AUTO_INCREMENT,
  product_name VARCHAR(100) NOT NULL,
  category VARCHAR(30) NOT NULL,
  price DECIMAL(10,2) NOT NULL,
  stock INT NOT NULL DEFAULT 0,
  note VARCHAR(100) NULL DEFAULT NULL,
  PRIMARY KEY (product_id),
  CONSTRAINT ck_p44_price CHECK (price >= 0),
  CONSTRAINT ck_p44_stock CHECK (stock >= 0)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO products_44_lab (product_id,product_name,category,price,stock,note) VALUES (1, '노트', '문구', 3500.00, 20, NULL),
  (2, '볼펜', '문구', 1500.00, 0, ''),
  (3, '머그컵', '생활', 8000.00, 12, '선물 포장'),
  (4, '스탠드', '생활', 25000.00, 5, NULL),
  (5, '파일', '문구', 1500.00, 50, ''),
  (6, '케이블', '전자', 8000.00, 0, '호환 확인');

The SQL retains the original Korean sample strings to exercise UTF-8 consistently. Product identifiers 1–6 represent a notebook, pen, mug, lamp, folder and cable; their category strings mean stationery, household and electronics. Enter the string literals as shown, use the identifiers when comparing results, and save the file with UTF-8 encoding.

SELECT COUNT(*) FROM products_44_lab;

The count is six. SELECT 1 succeeds without proving access to every intended database or table, so test actual required operations. Record useful error codes and sanitized messages rather than expose credentials in logs or screenshots.

Limit remote listening and network access to the required path

Confirm the actual private server address, port, allowed client origin and TLS policy with the administrator. An Ubuntu package may use /etc/mysql/mariadb.conf.d/50-server.cnf, but configuration locations vary. Back up the file and establish that the running server reads it before changing its server section.

[mariadbd]
bind-address = 10.0.0.10
port = 3306

10.0.0.10 is a private-address example, not an address guaranteed to exist on your machine. Use a real server interface, permit only required client origins through the network policy and account definition, and plan the disruption and reversal of any restart. Do not infer that the account host is automatically correct merely because the listener accepts packets.

Verify the remote certificate and account match

The next command assumes a real resolvable server and a trusted CA file. Replace db.example.internal and the path, and ensure the server name matches its certificate. A successful local test does not establish remote network or TLS correctness.

mariadb --protocol=tcp --host=db.example.internal --port=3306 --user=app_user --password --ssl --ssl-verify-server-cert --ssl-ca=C:/mariadb-lab/ca.pem

An approved SSH tunnel or VPN can provide a different path, but inspect the origin visible to the server and the resulting account match. Broad listening, wildcard origins or disabled certificate checks should not become habitual connection-error fixes.

Record the failure stage and reversible changes

For an unreachable server, inspect DNS, client address, listener, port and firewall. Once reachable, investigate account Host matching, authentication plugin and credentials. Unknown database and table-permission errors are later stages. Record configuration changes, original values and restarts and retain the path back to the prior policy. Remove only the disposable local table after reviewing its contents.

DROP TABLE shopcourse.products_44_lab;
More in This Category
MariaDB Tutorial / Start InnoDB Transactions with COMMIT and ROLLBACK

MariaDB Tutorial / Start InnoDB Transactions with COMMIT and ROLLBACK

Run a complete two-row InnoDB transaction, compare rollback and commit, and verify affected counts and balances. Understand connection scope, error handling, locks and implicit-commit boundaries.

MariaDB Tutorial / Install MariaDB on Ubuntu and Start the Server

MariaDB Tutorial / Install MariaDB on Ubuntu and Start the Server

Install MariaDB on Ubuntu with APT, distinguish service activity from automatic startup, and understand socket authentication. Create a restricted TCP learning account and diagnose connection or service problems.

MariaDB Tutorial / Save Reusable Query Definitions with VIEW

MariaDB Tutorial / Save Reusable Query Definitions with VIEW

Create an INVOKER view for paid-order totals, inspect its definition and observe transaction changes. Review security, updateability, dependencies and the difference between a view and stored result data.

MariaDB Tutorial / Calculate Running Totals and Compare Rows with LAG and LEAD

MariaDB Tutorial / Calculate Running Totals and Compare Rows with LAG and LEAD

Calculate running totals, LAG and LEAD, then compare ROWS and RANGE with tied timestamps. Verify how filtering before or after accumulation changes a period report.

MariaDB Tutorial / Compare NULL Correctly with IS NULL and COALESCE

MariaDB Tutorial / Compare NULL Correctly with IS NULL and COALESCE

Distinguish NULL from empty strings and zero, filter missing notes with IS NULL, choose COALESCE fallbacks and avoid NULL-related NOT IN surprises using reproducible product queries.

MariaDB Tutorial / Install MariaDB on Windows and Start the Server

MariaDB Tutorial / Install MariaDB on Windows and Start the Server

Set up a local MariaDB server on Windows, verify its service and TCP connection, and create a database-scoped learning account. Follow practical checks for installation, port, path, and authentication problems.

MariaDB Tutorial / Avoid Duplicate Totals When Joining Multiple Tables

MariaDB Tutorial / Avoid Duplicate Totals When Joining Multiple Tables

Trace row multiplication across customer, order, item and product joins. Reconcile correct goods and shipping totals, understand DISTINCT pitfalls and preaggregate details at the order grain.

MariaDB Tutorial / Calculate, Round, and Convert Numbers with ROUND and CAST

MariaDB Tutorial / Calculate, Round, and Convert Numbers with ROUND and CAST

Use exact DECIMAL inputs with ROUND and CAST, compare expected discount and midpoint results, and inspect conversion warnings, leading-zero loss and rounding-stage choices.

MariaDB Tutorial / Build and Reconcile Monthly Sales, Customer Totals, and Unsold Products

MariaDB Tutorial / Build and Reconcile Monthly Sales, Customer Totals, and Unsold Products

Create three related MariaDB reports from one order fixture, retain nonbuyers and find products without paid sales. Reconcile monthly and customer amounts and inspect join, status and date boundaries.

MariaDB Tutorial / Define Input Rules with NULL, DEFAULT, NOT NULL, and CHECK

MariaDB Tutorial / Define Input Rules with NULL, DEFAULT, NOT NULL, and CHECK

Distinguish missing values, empty strings, defaults, and required inputs in MariaDB. Run valid and deliberately invalid inserts, inspect CHECK enforcement, and restore settings without touching existing product data.