Is there a way to set a color scheme for the mysql client? It might sound trivial, but I'd like to be able to set some level of colors for terminal client.
-
2What terminal are you using? Or are you using Windows cmd.exe? This isn't really a mysql question. – Nick Dixon Dec 21 '09 at 14:20
-
1I'm using a Mac, regular Terminal. Though I could be using any terminal really. My thought was that maybe there was something like a .vimrc file for the mysql client. So, yeah it is a mysql question ;) – Cory Collier Dec 21 '09 at 14:38
-
Did you give any of these options a try? Did any of them work for you? – Matt Curtis May 14 '10 at 07:14
-
1It is a MySQL question. I just wondered about this too. I'm tired of the monochrome output of the MySQL client. It would be so much better in colours. Thought I'd check here first, the command line MySQL client doesn't have a color output option it seems. – Nov 22 '10 at 11:15
-
1fwiw, color is quite the opposite of trivial, especially if (like me) you've got a couple of 4k monitors on your desk and you need to visually process a lot of info that's coming at you all at once. – Jeff May 29 '18 at 07:11
9 Answers
I've spent much time trying to solve that question. It took me nearly a year to solve it :) There is nice option in mysql config called "pager".
I've just published my configs for mysql client and grc (availiable in most nix dists). Check it out on github! https://github.com/nitso/colour-mysql-console

- 1,511
- 1
- 12
- 25
-
3awesome! works a treat on osx (just `brew install grc` first). this makes me very happy :) – Darragh Enright Jan 23 '13 at 16:31
-
I followed the installation manual, but I did not find config files. "Copy both config files into your home directory" – Houssem ZITOUN Aug 19 '16 at 09:00
-
@HoussemZitoun config files are: [.my.cnf](https://github.com/nitso/colour-mysql-console/blob/master/.my.cnf) and [.grcat](https://github.com/nitso/colour-mysql-console/blob/master/.grcat) – Ostin Aug 19 '16 at 09:48
Here is pretty much awesome tool https://github.com/dbcli/mycli
Besides syntax highlight it offers completion.

- 4,227
- 4
- 34
- 35
-
1Perfect tool! I installed it in a sec `$ sudo apt-get install mycli` and the `$ mycli -u root -p root`. – alexandre-rousseau Mar 20 '17 at 15:52
-
You could use rlwrap if you just want a colour prompt:
% rlwrap --prompt-colour='1;34' mysql
Note: contrary to convention, rlwrap spells colour with a U.
If you want everything in colour, check out acoc - Arbitrary Command Output Colourer. Not sure if it works with interactive programs, you might need to extend it or write your own.

- 23,168
- 8
- 60
- 63
-
-
It seems you have to do: `rlwrap -a -p'RED' mysql` to get it working properly. Without the -a the prompt doesn't get coloured. – Neil Jul 07 '10 at 17:31
-
3@Neil: Sure, "colour" is how Australians spell it when writing, but most developers use "color" by convention for things like this because it avoids all sorts of unnecessary confusion. – Matt Curtis Jul 13 '10 at 00:17
-
IMHO you should lead with the acoc answer (which is why I upvoted you). Additionally, the link to rlwrap seems to be timing out. – Jeff May 29 '18 at 06:56
-
@Jeff thanks for the tip. rlwrap is easier to find on different platforms than acoc. It gets the silver medal though, that’s pretty good right? – Matt Curtis Jun 19 '18 at 13:36
Recently I have started to use the MySQL client inside an independent vim session with conque. You get syntax highlighting and some other extra features from Vim, like nowrap, search, horizontal scrolling, etc.
With :set wrap
:
With :set nowrap
:
If you like Vim I would give it a go:
- Install conque.
- Create a new .vimsql (I like a different vimrc for this).
- Tune it to start conque and mysql by default.
- Tune it to have some good key mappings for mysql.
alias mysqlcool="vim -u ~/.vimsql"
(or whatever :))
You can have a look at the vimrc I'm using.

- 5,857
- 3
- 29
- 44
Mysql text client is really basic, if you need something more advanced, you could try MySQL Query Browser, which is a GUI client.

- 18,889
- 4
- 46
- 89
Look up the program GRC on MacPorts.
I'm currently working on getting it running to colorize all of my terminal output. It uses regex to parse everything, so it really comes down to how much regex do you feel like writing.

- 1,956
- 18
- 18
For colorizing everything you need nothing but a simple echo
.
Since mysql has:
system (\!) Execute a system shell command.
you can easily:
But if you want only the prompt
be in color use rlwrap
And if you want to colorize the result of command you can use grc
It is a python script that I think read the underline stdout
, stderr
and then colorize it. You can configure it. And since it uses regex to match the result, in configure file you should write regex
More detail about ANSI color:

- 21,040
- 2
- 34
- 44
You should set color scheme for your terminal emulator or console window.

- 18,889
- 4
- 46
- 89
-
ehh, I already have a color scheme setup for my terminal. I'm looking for stuff specific to Mysql. For example, if every other row was a diff color, or if the prompt was a diff color, or the headers were a diff color. See where I'm driving here? – Cory Collier Dec 21 '09 at 14:45