Is there a way to save default MySQL connection parameters in a configuration file?
-
Is there a way to save the connection params(like host, port, username, password, db) to the mysql servers I frequently access as shortcuts? I am looking for something similar to [ssh config][1] for mysql from terminal in ubuntu. preferably with ssh tunneling support as well. [1]: http://linux.die.net/man/5/ssh_config
-
Answer:
You can tell mysql command line client to read additional groups with a given suffix in addition to the default [client] and [mysql] groups. See: http://dev.mysql.com/doc/refman/5.5/en/option-files.html#option_general_defaults-group-suffix For example: Add the following group to your users ~/.my.cnf or the global /etc/my.cnf [mysql_55] (or [client_55]) user=<user> password=<password> database=<database> host=<host> port=<port> # or # socket=<socket> Add as many or as few command options as you like. $ alias mysql55="mysql --defaults-group-suffix=_55" Then from the command line just call "mysql55" to login with the options stored in the [mysql_55] or [client_55] groups. To confirm what groups the alias is reading you can check the --help command. $ mysql55 --help | grep groups The following groups are read: mysql client mysql_55 client_55 Don't forget to add the aliases to your ~/.bashrc !
Matthew Montgomery at Quora Visit the source
Related Q & A:
- How to pass multiple parameters in a single Ajax function?Best solution by stackoverflow.com
- Is there a way of putting the Python Shell output in a tkinter window?Best solution by Stack Overflow
- What is the best way to save money?Best solution by Yahoo! Answers
- Is there any way of getting VHS tapes into a video file on a computer?Best solution by cnet.com
- Is there a way to send pictures from my computer to a cell phone?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.