11

Does anybody know if there is a way to make autocompletion work in MySQL Command Line Client under Windows? It's working nicely under Linux for me, but simply moves the cursor under Windows instead.

3 Answers 3

19

It ought to work this way:

C:\> mysql --auto-rehash 

Or configure your my.cnf:

[mysql] auto-rehash 

edit: My apologies. I have found some references that the tab-completion feature in mysql client works only on UNIX/Linux. It does not work on Windows.

update: The reason for this is mentioned briefly in MySQL bug #4731:

[31 Jul 2004 12:47] Sergei Golubchik

I just downloaded 4.0.15 - command completion in mysql.exe is NOT working, as expected. It was never working in mysql.exe because we were not able to make readline to compile with VC++.

mysqlc.exe is a cygwin build, and it is linked with readline.

Explanation: GNU readline is a standard open-source library for handling user input. The MySQL team uses the readline library, but they are not its author. From the above comment, I understand that they were unsuccessful in compiling the readline library on Windows with Microsoft Visual C++, the tool they use to build the MySQL product. Some open-source projects have not been made fully compatible with the Microsoft Windows environment.

At one time in the past, the MySQL product provided an alternative client they called mysqlc.exe, which they compiled with the cygwin toolset on Windows, but they don't provide this anymore. The cygwin toolset includes the readline library, so it was possible to compile the mysqlc.exe client with support for tab-completion.

So in theory, if you are really intrepid, you could download the cygwin toolset including the readline library, then download the MySQL source code and build it using cygwin. Then you should have a mysql client program that can perform tab-completion. But this sounds like a lot of work even for someone who is familiar with building MySQL from source.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks a lot for the super-detailed explanation. I think MySQL people should find a way to fix that even at a cost of using another library - I don't think it is impossible or that expensive. But yes we can hardly do anything until that.
I've actually found a Win32 Visual Studio-based build of readline: gnuwin32.sourceforge.net/packages/readline.htm - so maybe mysql people can re-use that.. Added as a comment to the bug you mentioned.
Presently there are mysql packages available for cygwin from its installer, no need to compile them.
1

This is probably not what you are looking for, but the enterprise version of SQLYog offers a somewhat limited schema auto-completion.

2 Comments

Thanks, SQLYog is a great tool, but sometimes command line is the best.
not sure why they can't just look at postgres client source code much better and ctrl-c doesn't boot you out (retard).
1

If above dosen't work and you use widnows 10 you can install linux shell, then install mysql-client and connect like in terminal in linux where autocomplite works.

Instruction: https://learn.microsoft.com/en-us/windows/wsl/install-win10

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.