Mysql Color Scheme

16,304

Solution 1

Here is pretty much awesome tool https://github.com/dbcli/mycli

Besides syntax highlight it offers completion.

enter image description here

Solution 2

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

enter image description here

Solution 3

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.

Solution 4

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:

enter image description here

With :set nowrap:

enter image description here

If you like Vim I would give it a go:

  1. Install conque.
  2. Create a new .vimsql (I like a different vimrc for this).
  3. Tune it to start conque and mysql by default.
  4. Tune it to have some good key mappings for mysql.
  5. alias mysqlcool="vim -u ~/.vimsql" (or whatever :))

You can have a look at the vimrc I'm using.

Share:
16,304
Cory Collier
Author by

Cory Collier

Updated on June 14, 2022

Comments

  • Cory Collier
    Cory Collier about 2 years

    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.

  • Cory Collier
    Cory Collier over 14 years
    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?
  • Neil
    Neil almost 14 years
    "color" is just the American way to spell it.
  • Neil
    Neil almost 14 years
    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.
  • Matt Curtis
    Matt Curtis almost 14 years
    @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.
  • Darragh Enright
    Darragh Enright over 11 years
    awesome! works a treat on osx (just brew install grc first). this makes me very happy :)
  • Houssem ZITOUN
    Houssem ZITOUN almost 8 years
    I followed the installation manual, but I did not find config files. "Copy both config files into your home directory"
  • Ostin
    Ostin almost 8 years
    @HoussemZitoun config files are: .my.cnf and .grcat
  • alexandre-rousseau
    alexandre-rousseau over 7 years
    Perfect tool! I installed it in a sec $ sudo apt-get install mycli and the $ mycli -u root -p root.
  • Cory Collier
    Cory Collier over 6 years
    I've found this tool recently, and I absolutely love it!
  • Jeff
    Jeff about 6 years
    IMHO you should lead with the acoc answer (which is why I upvoted you). Additionally, the link to rlwrap seems to be timing out.
  • Matt Curtis
    Matt Curtis about 6 years
    @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?