by Tim Hunt.
That is what the Database authentication method is for: https://docs.moodle.org/28/en/External_database_authentication