Easy MySQL server login trick

December 15, 2006

I just discovered a new MySQL tip today that I sub-consciously wanted. A way to type one command and be logged into MySQL server when I was on the production machine. Here is how you do it:

Create a file .my.cnf in your home directory. Put the following entry into it:


Then create a file in /usr/local/bin called db or whatever, and put this in it:

mysql db_name

Now from anywhere in the terminal you can type . db and automatically have a mysql prompt. Lovely!


One Response to “Easy MySQL server login trick”

  1. phrog Says:

    If you don’t have root you can insert your script in ~/bin instead of /usr/local/bin and ad ~/bin to your PATH in your .bash_profile

    That way when you need to back stuff up your not looking all over the server for your scripts they are all in your ~/

    There is no place like ~/


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: