views:

114

answers:

1

Using mysql directly from the command line (running on Ubuntu 9.10, standard bash terminal), I am unable to use certain keyboard buttons like:

Delete, Control-(arrow right), Control-(arrow left)

Which gets returned to me as:

~;5C;5D

respectively. I'm assuming there must be a flag in mysql that fixes this but I have been unable to find one. Is there a .mysqlconfig file to edit to make this happen on startup?

+1  A: 

According to this thread and mysql --version, mysql is compiled with editline instead of readline. From that thread:

I had to add create an .editrc file with the following lines to get ctrl-R and DELETE to work.

bind "\e[3~" ed-delete-next-char 
bind "^R" em-inc-search-prev

Although that didn't work for me.

Another suggestion from that thread did work:

$ sudo apt-get install rlwrap

Then add an alias in ~/.bashrc

alias mysql='rlwrap -a mysql'

This problem may be specific to Ubuntu 9.10

Dennis Williamson
The last post on the thread worked for me! (accepted for the find) Reproducing the code used here:$ sudo apt-get install rlwrap$ alias mysql='rlwrap -a mysqlSo basically it seems you are wrapping another program around mysql to get back the vi-like bindings. From the other comments on the thread it seems like this is a bug with Karmic itself.
Hooked
The rlwrap alias works for me also.
Dennis Williamson
This solution seems to handle other terminal-like issues (it worked for Mathematica and MAPLE as well).
Hooked