First, set mysql on the database server for remote access. Secondly, open the firewall policy on the linux system where the database server is located and add port 3306. Finally, configure the network environment so that two machines can communicate.
It is enough for other java projects to configure the ip and username password of the database.