Mysql – Fix Control-C in thesql command line programme

keyboardkeyboard shortcutsMySQLpostgresql

In the mysql command line, pressing Control-C will cancel the programme, and bring you back to bash. In psql, the one for postgres, it will kill the current query and will not stop the psql programme. Is there any way to get the psql style behaviour for Control-C in the mysql programme? I keep finding myself pressing Control-C by habit and having to log back into mysql.

Control C doesn't kill bash, and log you out when you press it. Which I think is a good thing. Control-C means 'stop what you're doing'.

Best Answer

If you press Ctrl-C in 5.1 during query execution, it will halt the execution with the message "Query execution was interrupted"

    mysql> INSERT INTO c SELECT rand()*1000, sha1(rand()) FROM c;
    Query aborted BY Ctrl+C
    ERROR 1317 (70100): Query execution was interrupted

A further Ctrl-C press kills the client.

Older versions die horribly as noted in question, so upgrade if possible :)

Edit:

Looks like it was added in 5.0.25 (and 5.1.10).

Related Topic