Use linux account to get secure connection to MySQL and MariaBD without password

No need to remember your password to connect to a linux server, SSH keys provide authentication. We can have the same thing on MySQL and MariaDB.With a plugin, the database server trusts the credentials of the linux system, you only need mysql account with the same name as the linux account and the password disappears from the connection. It is ideal on a development server with multiple users and it greatly facilitates the management of accounts, even if we forget to delete the mysql account, deletion of the linux account is enough.

This article will cover MySQL and MariaDB. There are similar but query syntax have minor difference. The auth_socket plugin is available from MySLQ 5.5 and MariaDB 5.2. I tested query with MySQL 5.5 and MariaDB 5.5 and 10.1.

First we need to enable the auth_socket plugin; a simple query is enough and must be run with root user.