In MySQL
credentials are per client, so we distinguish a couple of client types:
- localhost
means the same machine as MySQL server connecting via Unix Socket
- 127.0.0.1
means the same machine as MySQL server connecting via TCP/IP
- A.B.C.D
where letters are replaced by numbers in range 0-255 which means IP address of client machine connecting via TCP/IP
- *
is a wildcard which means that any client can connect with given credentials via TCP/IP
Every entry in MySQL
users table consists of client specification (described above), username, password and some other columns (not relevant here).
So the problem you are facing is that PHP script on 1and1 server can connect to the database hosted on 1and1 since the hosting company sets up their database server to accept connections from their own servers with valid credentials.
But the same credentials are considered invalid for connections coming from client machines unknown to 1and1.
What you can do is to ask 1and1 to give your specific IP access rights to your database.
What you can't to is to overcome this problem on your own.