Either both use IP of server1 or server1 uses 127.0.0.1 and server2 the IP of server1. So if your configurations is using the WAN-IP, both server config should match completely, otherwise 127.0.0.1/WAN-IP.
The server should know this automatically since your config points to the correct server.
BTW; did you allow external connections for the MySQL server on server1? (Otherwise this wont work.)