Emmanuel
Emmanuel

Reputation: 5395

PHP & MYSQLI, why won't it even try connect to remote host?

My code is simply:

$connection = new mysqli('52.62.xx.xx', $myUsr, $myPwd, $myDB, '3306');

The strange thing is that the IP address, or remote host, is being replaced with the IP address of my server, and I get the following error:

Access denied for user 'myUsr'@'107.191.xx.xx'

Why is mysqli trying to connect to 107.191.xx.xx when I'm explicitly telling it to connect to 52.62.xx.xx

What am I missing here?

I don't think it's too relevant, but the remote host is an Amazon Aurora instance.

EDIT:

Ok, so on the HOST server I ran: GRANT ALL PRIVILEGES ON *.* TO 'myUsr'@'107.191.xx.xx' IDENTIFIED BY 'password'

Now it works :)

Upvotes: 0

Views: 808

Answers (2)

newman
newman

Reputation: 2719

This

`Access denied for user 'myUsr'@'107.191.xx.xx'`

mean that user myUsr tried connect from IP 107.191.xx.xx. This is your IP address of server with your script.

You should configure the HOST mysql server to allow myUsr to connect from this IP or from all addresses.

Upvotes: 3

SADIK Younsse
SADIK Younsse

Reputation: 166

Hi you must grant your user to connect from the your local IP remotely to mysql server, your user doesn't have the right to use remote connection to mysql you can try this command to make your user able to connect to mysql server from you local IP address GRANT ALL ON youDB.* TO youUser@'YOUR_LOCAL_IP' IDENTIFIED BY 'USER_PASSWOR';

Upvotes: 0

Related Questions