$linuxjunkies
>

mycli(1)

A terminal-based MySQL client with syntax highlighting, auto-completion, and smart suggestions.

UbuntuDebianFedoraArch

Synopsis

mycli [OPTIONS] [DATABASE]

Description

mycli is a command-line interface for MySQL and MariaDB that improves upon the standard mysql client with modern terminal features. It provides syntax highlighting, intelligent auto-completion based on database schema, history search, and formatted query output.

Connect to local or remote MySQL servers, execute queries interactively or in batch mode, and navigate databases with a user-friendly interface that supports vi-key bindings and mouse interaction.

Common options

FlagWhat it does
-u, --userMySQL user name
-p, --passwordPrompt for password (or provide directly, not recommended)
-h, --hostHost address of the MySQL server (default: localhost)
-P, --portPort number to connect to (default: 3306)
-e, --executeExecute query and exit without entering interactive mode
--no-auto-escapeDisable automatic escaping of special characters in input
--single-connectionUse a single connection for all queries instead of per-statement
--sslUse SSL for the MySQL connection
-A, --auto-vertical-outputAutomatically switch to vertical output when result is too wide
--login-pathRead connection parameters from a named .mylogin.cnf entry

Examples

Connect to local MySQL server as root user and open database mydb interactively

mycli -u root -h localhost mydb

Connect to remote MySQL server with password prompt and select production database

mycli -u admin -p -h db.example.com production

Execute a single query and exit without entering interactive mode

mycli -u user -p -e "SELECT * FROM users LIMIT 5;" mydb

Connect using credentials stored in .mylogin.cnf under the 'myserver' profile

mycli --login-path=myserver

Connect and automatically switch to vertical output for wide result sets

mycli -u root -A mydb

Connect to non-standard port 3307 on a remote server

mycli -u admin -p -h 192.168.1.100 -P 3307 testdb

Related commands