2

With mysql command line client on Ubuntu 14.04 I could bind UP to a backward command search by adding the following lines to ~/.inputrc

# type a word, hit up and a search is performed
# "\e[A": history-search-backward

This inputrc setting would be read and provide customised bindings in MySQL command line, i.e. start interactive MySQL command line:

% mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.7.12-0ubuntu1 (Ubuntu)

Then once in I could type a word and hit UP and the mysql command line would perform a backward search through the command history based on the word:

mysql> select <UP>

would give results like

mysql> select * from user;

I literally had the same settings in 14.04 and they worked, now in ubuntu 16.04 and mysql-client-5.7 this doesn't work, instead I simply get the default behaviour of showing previous commands in chronological order.
How can I get the UP key to perform a command history search in mysql command line?

  • Does this work in other programs that use readline, such as bash and rlwrap? – Gilles Jun 3 '16 at 21:26
  • @Gilles I believe so. an SQLite prompt seems to read my ~/.inputrc. I discovered that this version of MySQL 5.7.x is compiled using editline library - Im pretty sure thats the problem. – the_velour_fog Jun 3 '16 at 21:33
  • That would do it. Please post this as an answer! – Gilles Jun 3 '16 at 21:40
2

I discovered that this version of MySQL 5.7.x on ubuntu 16.04 is compiled using editline library not readline - Im pretty sure thats the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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