LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

mycli

MySQL client with autocompletion and syntax highlighting

TLDR

Connect to database
$ mycli -u [username] [database]
copy
Connect to remote host
$ mycli -h [hostname] -u [username] [database]
copy
Connect with password prompt
$ mycli -u [username] -p [database]
copy
Execute SQL file
$ mycli -u [user] [database] < [script.sql]
copy
Connect via socket
$ mycli -S [/var/run/mysqld/mysqld.sock] -u [user]
copy
Use specific port
$ mycli -h [host] -P [3306] -u [user] [database]
copy
Execute a query and exit
$ mycli -u [user] -e "SELECT * FROM [table]" [database]
copy
Output results as CSV
$ mycli -u [user] -e "SELECT * FROM [table]" --csv [database]
copy

SYNOPSIS

mycli [options] [database]

DESCRIPTION

mycli is a command-line client for MySQL, MariaDB, and Percona with smart autocompletion and syntax highlighting. It provides context-aware completion for SQL keywords, table names, column names, and functions as you type.

PARAMETERS

DATABASE

Database name to connect.
-h HOST
MySQL server hostname.
-u USER
Username.
-p [PASSWORD]
Password (prompt if no value).
-P PORT
Port number.
-S SOCKET
Unix socket path.
-D DATABASE
Database name to connect to.
-e COMMAND
Execute command and quit.
-R PROMPT
Customize the prompt format.
--csv
Output results in CSV format (batch mode).
--table
Output results in table format (batch mode).
--auto-vertical-output
Automatically switch to vertical output when result is wider than terminal.
-d DSN
Use DSN configured in the [alias_dsn] section of myclirc file.
-l FILE
Log every query and its results to a file.
-v, --verbose
Verbose output.
--myclirc FILE
Path to configuration file (default: ~/.myclirc).
--defaults-file FILE
Only read MySQL options from the given file.
--warn / --no-warn
Warn before running a destructive query.
--ssh-host HOST
Host name to connect to ssh server.
--ssh-port PORT
Port to connect to ssh server.
--ssh-user USER
User name to connect to ssh server.
--ssh-key-filename FILE
Private key filename for the ssh connection.
--ssl-ca PATH
CA file in PEM format.
--ssl-cert PATH
X509 cert in PEM format.
--ssl-key PATH
X509 key in PEM format.
-V, --version
Display version information.
--help
Display help information.

CAVEATS

Python-based; requires a running MySQL/MariaDB/Percona server to connect to. Configuration is stored in ~/.myclirc.

HISTORY

mycli was created by Amjith Ramanujam as a user-friendly MySQL CLI with autocompletion, inspired by pgcli.

SEE ALSO

mysql(1), mariadb(1), mysqldump(1), pgcli(1), litecli(1)

Copied to clipboard
Kai