mariadb
Access and manage MariaDB databases
TLDR
Connect to a specific MariaDB database
Connect to a specific MariaDB database using username and password
Show warnings after every statement in interactive and batch mode
Display less verbose outputs (can be used multiple times to produce less output)
Execute SQL statements from a script file
Check memory and open file usage at exit
Connect using a socket file for local connections
Display help
SYNOPSIS
mariadb [options] [db_name]
PARAMETERS
-?, --help
Display help message and exit
--version, -V
Show version information
-h, --host=name
Connect to specified host (default: localhost)
-P, --port=port_num
TCP/IP port number (default: 3306)
-S, --socket=path
Unix socket file or Windows named pipe
-u, --user=name
MariaDB username (default: login name)
-p, --password[=name]
Password; if omitted, prompts interactively
-D, --database=name
Database to use upon connection
-e, --execute=statement
Execute SQL statement and exit
--connect_timeout=seconds
Timeout for connection establishment
-t, --table
Display output in table format
--auto-rehash
Enable automatic rehashing for tab completion
--ssl-mode=mode
SSL connection mode (REQUIRED, PREFERRED, etc.)
-v, --verbose
Verbose output
--comments
Preserve SQL comments in statements
DESCRIPTION
The mariadb command is the primary client tool for interacting with a MariaDB database server, an open-source fork of MySQL designed for enhanced performance and community-driven development. It enables users to connect to a local or remote MariaDB instance, execute SQL queries interactively, run scripts from files, or perform one-off statements via batch mode.
Upon invocation, it prompts for SQL input if no statements are provided, supporting commands like SELECT, INSERT, UPDATE, and administrative tasks such as CREATE DATABASE or SHOW TABLES. Features include command history (via arrow keys), auto-completion (double-tab), output formatting (tabular, vertical, etc.), and variables for scripting. Connection details like host, port, user credentials, and default database are configurable via options or ~/.my.cnf files.
Ideal for database administrators, developers, and automation scripts, it mirrors MySQL client syntax for easy migration. Secure practices recommend avoiding plaintext passwords on the command line to prevent exposure in process lists. Supports SSL/TLS for encrypted connections and compression for bandwidth savings. Exit with \q, exit, or Ctrl+D.
CAVEATS
Passwords on command line appear in process lists; use ~/.my.cnf or interactive prompt. Not for starting the server (use mariadbd). Limited to client functions; no direct server control.
CONFIGURATION FILES
Reads options from /etc/my.cnf, ~/.my.cnf in INI format under [client] or [mariadb] sections.
Example:
[client]
host=localhost
user=root
COMMON EXAMPLES
mariadb -u root -p mydb — Connect interactively to 'mydb'.
echo 'SELECT * FROM users;' | mariadb -u root mydb — Batch query.
mariadb -e "SHOW DATABASES;" — Quick list databases.
HISTORY
Originated as MySQL client; renamed mariadb in MariaDB 10.2 (2017) to distinguish from Oracle-owned MySQL. MariaDB project forked from MySQL 5.1 in 2009 by Monty Program AB for open governance.


