Comments - How to access MariaDB from a Linux systemd service without password
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.
The systemd service has ProtectHome=yes by default making the /root/.my.cnf file inaccessible to the systemd service.
While disabling with ProtectHome=false may seem like the easy option, consider the alternative:
Ref: unix socket authentication.
With this the /root/.my.cnf file is no longer needed, and the root unix user is the only one that can access the root@localhost MariaDB user account.
If your systemd service runs under a different user, say xyzservice, then;
And then provide the sufficient grants to that user based on what the service needs.