I am looking for a simpler way to log in to MySQL
through the terminal without having to input my username and password each time.
I am using MAMP
and to access my databases, I just simply type mysql
and it is accessed. To do that I just created a symbolic link ln -s /Applications/MAMP/Library/bin/mysql /bin
but to be able to create databases and such I need to be logged in. I know I can do that by typing mysql -uroot -ppassword
but that's a bit of a pain to type each time. Is their a way to use a symbolic link like to add attributes? Say like ln -s /Applications/MAMP/Library/bin/mysql -uroot -ppassword
?
Symlinks cannot contain command-line options.
You could instead place your credentials in an option file. If stored in a default location (such as ~/.my.cnf
), you won't even need to tell mysql
to read it.
[client]
user=root
password=foobar
Beware, especially if doing this for the root user, that anyone with read access to your option file will be able to login as your user.