Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a MySQL terminal prompt that supports things like tab-completion and history? The standard one that comes with MySQL doesn't have those features

share|improve this question
Usually, mysql is built with readline capabilities, which includes all the things you mention. What operating system are you on, how did you install MySQL, and what version of MySQL are you using? – Kusalananda Sep 14 '11 at 15:17
up vote 1 down vote accepted

I can only speak from Linux experience, but the MySQL command line tool is chock full of options, including the two that you mention.

Tab completion is as simple as pressing the Tab key to expand database, table, and column names. From the MySQL docs:

To complete a name, enter the first part and press Tab. If the name is unambiguous, mysql completes it. Otherwise, you can press Tab again to see the possible names that begin with what you have typed so far. Completion does not occur if there is no default database.

Tab completion is enabled by default, however, it can be turned off by adding no-auto-rehash to the [mysql] section in your my.cnf file. It can also be disabled by passing the -A flag. So make sure you're not using any of those settings if you want tab completion turned on. If all else fails just type rehash at the mysql prompt after selecting a database.

As far as history... MySQL saves every query you execute in $MYSQL_HISTFILE, which defaults to ~/.mysql_history. Simply, pressing the Up and Down arrows will scroll through your history. If you want more advanced searching, mysql is compiled with the GNU readline library so all you need to do is type ctl-r and you can then perform a reverse history keyword search.

For more information check out:

The MySQL Command-Line Tool

The GNU Readline Library

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.