Why no autocomplete in mysql with bash?

I switched my shell to bash so I could have tab auto-complete, but although it works fine at the command line generally, it doesn't work from the mysql prompt. Anyone know the answer? I couldn't find it searching here or google (admittedly not extensively). Thanks!
 
The mysql prompt and its editing functions are implemented by the mysql client program, not the shell.
 
Lido said:
I switched my shell to bash so I could have tab auto-complete, but although it works fine at the command line generally, it doesn't work from the mysql prompt. Anyone know the answer? I couldn't find it searching here or google (admittedly not extensively). Thanks!

I think that the mysql's shell does not handle completion. rlwrap could help (in port devel/rlwrap). I do not use it with mysql but rlwrap is a nice tool.

(example : http://blogs.linux.ie/kenguest/2011/04/20/adding-colour-to-your-mysql-prompt/ or
http://www.idevelopment.info/data/Oracle/DBA_tips/SQL_PLUS/SQLPLUS_8.shtml
)

HTH, regards.
 
Thanks plamaiziere. I will investigate rlwrap. Not sure if it's bad form to mention this, but every Linux distribution I've ever used seems to have mysql with autocomplete. Do you know if they wrap the cl by default?
 
Hmm, I've used MySQL for years and never even knew it had autocomplete!

As others have said, as soon as you enter the MySQL CLI (with the mysql> prompt) everything is handled by the client executable and has nothing to do with your shell.

On the server I just tried (MySQL 5.5-13), I was able to enable autocomplete by running it as follows:

Code:
# mysql --auto-rehash -p

The man page says this is default though so I'm not sure what's been done to the FreeBSD port to stop this working without manually specifying the option. (I can't tell if this still happens if MySQL is installed from source manually)
 
Thanks Matt! Went to my.cnf and commented out the "no-auto-rehash" line that was in there because of the config file I picked (probably medium). Fixed.
 
Back
Top