Linux – Allow linux root user thesql root access without password

linuxMySQLpasswordrootSecurity

On cPanel when I am logged in as root and type "mysql" without hostname and password it gives me direct access to mysql root user.

I would like to do this for one of my non-cpanel server where the linux root user gets password less logon to mysql root user in the same way as it does on cPanel.

Is this possible ?

Best Answer

The easiest way to do this is to use a client section of the ~/.my.cnf file, and add the credentials there.

[client]
user=root
password=somepassword
...

it's a good idea to make that file readable only by root too.