Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autocomplete in MySQL under Windows

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.

like image 990
Michael Pliskin Avatar asked Nov 06 '08 18:11

Michael Pliskin


People also ask

How do I enable autocomplete in MySQL workbench?

Preferences: SQL Editor: Query Editor Enabled by default. This option automatically executes the code autocomplete feature while editing SQL in the SQL editor. If disabled, you can instead use the keyboard shortcut Modifier + Space to execute the autocomplete routine.

How do I auto fill in MySQL?

MySQL Shell supports autocompletion of text preceding the cursor by pressing the Tab key. The Section 3.1, “MySQL Shell Commands” can be autocompleted in any of the language modes. For example typing \con and pressing the Tab key autocompletes to \connect .

How do I set environment variables in MySQL Windows 10?

On the Windows desktop, right-click the My Computer icon, and select Properties. Next select the Advanced tab from the System Properties menu that appears, and click the Environment Variables button. Under System Variables, select Path, and then click the Edit button. The Edit System Variable dialogue should appear.


2 Answers

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://docs.microsoft.com/en-us/windows/wsl/install-win10

like image 63
paka Avatar answered Oct 13 '22 21:10

paka


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.

like image 30
Bill Karwin Avatar answered Oct 13 '22 22:10

Bill Karwin