A. Dravid
A. Dravid

Reputation: 43

Remote mysql connection through wamp

 MySqlConnection con = new MySqlConnection("Server = 'ip_adress'; Database = 'db'; Uid = 'root'; Pwd = 'test'; SslMode = none");

Hello! I am trying to connect to my mysql database using my ip instead of localhost. Using localhost everything is fine but it can't connect when i am using the ip. I followed most if not every thread on the subject but i still can not fix it. I am able to connect to phpmyadmin using the ipadress, i granted full privileges to root, set host to %, port forwarded 3306 and 80. I appreciate every bit of help. Thank you

Upvotes: 1

Views: 6815

Answers (1)

James Wong
James Wong

Reputation: 4619

Since it worked out for you, am gonna post this as an answer :) What shed the light into your situation is that you mentioned the MySQL port binding in the config is set to

bind-address = 127.0.0.1

The above config meant MySQL only listens to incoming requests from localhost. To have it listening to all interfaces, change it to

bind-address = 0.0.0.0

There might be security risks associated with listening on all interfaces. Those risk can be mitigated by whitelisting specific IP addresses by either defining users from specific host or adding firewall rules at network level.

CREATE USER 'dbuser'@'192.0.0.100';

Reference:

Glad it worked out for you in the end, and enjoy your stay at SO. Cheers!

Upvotes: 3

Related Questions