Passwordless access to MySQL by using sudoma. 19 mars 2012
Tired of remembering root passwords for MySQL on your servers? Fear no more, help is on the way.
I'll assume that you have a Linux system set up with sudo and mysql already installed. Fire up a terminal and type
Open up \~/.my.cnf in your favorite editor (the \~ points to the root account now).
and add the following contents:
[client] user = root password = yourpassword
Follow up with logging out of root:
And run sudo to start MySQL. Remember to use the -H option to point all requests for \~ to root's home directory:
sudo -H mysql
It is a simple as that :)