Skip to content
Latchkey

mycli: Usage, Options & Common CI Errors

mycli is a MySQL CLI with autocompletion and syntax highlighting.

mycli is the MySQL counterpart to pgcli - nicer interactively, occasionally used for CSV output in CI. Like pgcli it is a Python package and inherits MySQL's access-denied quirks.

What it does

mycli connects to MySQL/MariaDB like the mysql client but adds autocompletion, highlighting, and friendlier output. It accepts the usual host/user/password flags and can run a single statement with -e.

Common usage

Terminal
pip install mycli
mycli -h 127.0.0.1 -u root -psecret app
mycli mysql://root:secret@127.0.0.1:3306/app
mycli -h 127.0.0.1 -u root -psecret -e 'SELECT 1' app
mycli --csv -h 127.0.0.1 -u root -psecret -e 'SELECT * FROM t' app

Options

ItemWhat it does
-h / -u / -p[pass]Host / user / password (attached)
mysql://... URLConnection string form
-e "SQL"Run one statement and exit
-D / <db>Default database
--csvCSV output

Common errors in CI

mycli: command not found - install via pip install mycli (it is not part of the mysql-client package). The -p password must be attached with no space (-psecret) just like the mysql client, or you get ERROR 1045 Access denied. Use -h 127.0.0.1 (not localhost) to force TCP to a service container. For scripted output, mycli --csv -e is parseable; otherwise prefer the plain mysql client in pipelines.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →