Hi andy zhu,
You have to use custom login functionality for this.
Sync Users:
Create A module which can connect to your external database via Mendix external DB connector ( Check if the Module supports your database); if external database connector is not supported, you can create your own java action in Mendix to connect to your Database ( https://docs.mendix.com/howto8/logic-business-rules/extending-your-application-with-custom-java/) and then Sync Users ( also check if you can Use Rest service to connect) .
Once the above is achieved , create a flow and call it via Scheduler, and configure your timings
You will have to create an account object of entity where system.user is generalized.
During the login, Call the service which connects to your database, validate and then allow to the application.
For your reference:
https://community.mendix.com/link/space/app-development/questions/128346
https://medium.com/@jfvdkd/building-an-unrivaled-user-experience-crafting-a-customized-mendix-login-page-76ab9f4b6d1d
https://community.mendix.com/link/space/security/questions/99450
I hope this can boost you to start. ATB!!