Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
5  
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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.