1

I am using the msyql-client, and I open a mysql prompt on a terminal via:

$ mysql -h localhost -uuser -ppassword
mysql> 

I use the msql client version:

Ver 14.14 Distrib 5.7.17, for Linux (x86_64) using  EditLine wrapper

For terminals with emacs-like bindings, I have a very strong muscle memory to use

Ctrl + W

to delete the last word. Yet inside the mysql client, it deletes back to the start of the line and hence it's hard for me to write or adapt queries.

Can I rebind the keyboard shortcuts for mysql client and, if so, how? I know that I can use Alt + Backspace instead, yet I want to keep my usage consistent.

8
  • Ctrl-w is a readline function, it should work the same in all readline-enabled applications. If it doesn't work in mysql then your mysql might be compiled without it. You can check with mysql --version (it should say something like "... using readline 5.1"). Mar 29, 2017 at 10:19
  • @SatoKatsura I see mysql Ver 14.14 Distrib 5.7.17, for Linux (x86_64) using EditLine wrapper; I guess "EditLine" is not the same as "ReadLine"?
    – k0pernikus
    Mar 29, 2017 at 10:20
  • Nope. Complain to the maintainer. Mar 29, 2017 at 10:21
  • @SatoKatsura Is readline a de-facto standard? editline is marketed as a readline alternative without ncurse, so the maintainer might have thought of it as a feature.
    – k0pernikus
    Mar 29, 2017 at 10:23
  • Well, it isn't readline, thus the difference with Ctrl-w. No idea if / how it can be configured to do what you want. shrug Mar 29, 2017 at 10:25

2 Answers 2

2

As a workaround, I installed mariadb, the community-driven fork of mysql, and use its mysql client, since that client comes with readline:

sudo apt install mariadb-client
mysql --version
mysql  Ver 15.1 Distrib 10.0.29-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

You can use just the same as the mysql client.


Keep in mind that it will uninstall mysql, even though I consider this a feature.

It appears the maintainers of mysql dropped readline in favor of editline due to licensing reasons. (Editline seems to be BSD, readline is GNU, and the latter seems to conflict with their desire for providing a commercial version.)

These are the relevant bug reports I found in that regard:

1

Some versions of the mysql client, on some platforms/distributions, are built against editline rather than readline for software licensing reasons.

editline's default binding for Ctrl+W often is to delete the entire line up to the cursor position. The way to change that binding to instead delete only the preceding word is to create a file named .editrc in your home directory with the following contents:

bind "^W" ed-delete-prev-word

The mysql client will pick up on this the next time you start it.

(source)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .