cat /etc/pam.d/mariadb #%PAM-1.0 # Use password-auth common PAM configuration for the daemon auth include password-auth account include password-auth
Depending on the distribution you use, the file might be a little different, but basically you just add the default settings. Then you change the mysql configuration file using your favorite editor:
emacs /etc/my.cnf
[mysqld] plugin-load=auth_pam.so
You should check that this plugin is installed on your system. Then you (re)start the mysql servide:
systemctl start mysqld.service
Next you login to the database as the root user
mysqladmin -u root password
Then you can grant permissions on users that are available through pam:
GRANT ALL ON *.* TO username@localhost IDENTIFIED VIA pam USING 'mariadb'; flush privileges;
After that, the user can now login to mysql with:
mysql -u username -p
Note that the string "mariadb" after USING in the grant query refers to the pam configuration filename that you used.