I often use the mysql command-line client on an Ubuntu box. It works fine, except that the key bindings are wrong. Specifically, pressing "Home", "End", or "Delete" makes it output a ~ (tilde) character, and beep.
I've determined that Home/End can be done by pressing Control+A and Control+E respectively, as on the Mac terminal. I'm on a Windows box, using PuTTY to talk to Ubuntu, but the home/end/delete keys work fine on the regular command line. I'm pretty sure it's an issue specific to the mysql client.
I checked the man file but didn't find anything useful. Is there any way to bind the Home/End/Delete keys to their actual functions? Maybe a config file in my home directory or something?
Every time I move back a few spaces to edit a query and press delete, I just wind up having to go forward again so I can use the Backspace key to delete not only the incorrect query but also the ~ that the delete key puts in.
It's driving me slowly but surely to madness. Madness, I tell you, MADNESS!
Okay, I noticed that my home server did not have the problem, and comparing the work and home servers let me finally nail it down.
It's a bug Ubuntu introduced in version 9.10, which is what my work server is running. Specifically, the version of /usr/bin/mysql in Ubuntu 9.10 uses the EditLine wrapper instead of the readline wrapper:
Compare to the more recent release on my home server:
The 10.04 (and presumably later) versions work just fine -- mysql honors the home/end/delete keys using Putty's default settings.
So the solution is either to upgrade the server to 10.04 or later, or to use the command line utility
rlwrap
to wrap the mysql client in a readline environment, as described in the blog post restoring readline capabilities of Ubuntu's 9.10 (Karmic Koala) MySQL Client.Sadly, the
rlwrap
approach has the nasty side effect of making your password visible when you type it in instead of suppressing its output. So I think I'll take the upgrade route.I'd say the problem is your PuTTY settings - in the connection window, under "Terminal", "Keyboard" - change options for "The Home and End keys" to
rxvt
. Not perfect (End won't work still) but you'll get Home and Delete.IMO the real solution is to use a proper terminal & proper SSH; Console2 is reasonably good for a terminal, and MSYS or Cygwin can give you SSH (msysgit has it included).
Edit:
Sounds like you've found the bug in MySQL CLI.