Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect from mysql client from one host to multiple host with .my.cnf client file

Tags:

database

mysql

I have configured multiple databases in my.cnf file and trying to use them via command line mysql.

My config looks like this:

[client] host=abaabs user=asdads password=vxcvx database=zdxew [client_read] host=12312 user=34534 password=546456 database=6786786 And when i say mysql on command line i get by default client config as the default database. How do I select the second database on mysql cmd?

like image 417
amitchhajer Avatar asked Oct 19 '25 17:10

amitchhajer


1 Answers

On command line $ mysql --defaults-group-suffix=_read for the client_read database.

You may wish to make an alias for a given database using something like:

$ alias myreaddb "mysql --defaults-group-suffix=_read"

like image 154
amitchhajer Avatar answered Oct 21 '25 08:10

amitchhajer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!