Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I just setup my first database with MySQL and connected it through Visual Studio.
When I setup the Database on Visual Studio I get prompted with a window called "Add Connection"

and the fields are
Data Source
Server name:
User name:
Password:
[] Save my password
Database name [Dropdown list]

And when i connect my MySQL Database I fill it out like this..

Data Source
Server name: localhost
User name: root
Password: password
[] Save my password
Database name [name of the database]

And if I debug the software and send it to a friend and he tried to open it.. he cant because the server is set on the localhost and he doesnt have the server on his computer.

How do I change it to where I can connect to the database through a IP.. lets say I want to use my IP as a server connection.. Where would I change that?

I'm assuming it would be in MySQL > Manage Server Connections > New and then ass the ip as the host name..

But what IP do I add and do I need to portforward?
Do I add my IPV4 or the one I see at http://cmyip.org

What I have tried:

I didnt try anything yet because I didnt want to mess things up before I ask the question to the point where I cant restore things.
Posted
Updated 7-Dec-16 9:11am

1 solution

MySQL has the IP address of your PC. Because MySQL is installed on the same PC as the program accessing it you can use localhost or 127.0.0.1 to connect and access MySQL or you can use your PC's actual IP address or the network name of your PC.

If your friend is on the same network as your PC then they can use the IP address or name of your PC on that network so long as your PC's firewall has a rule to allow it.

If your friend is not on the same network then you will have to allow access from the internet to your PC, usually via a VPN.
 
Share this answer
 
Comments
Christoffer Nilsson 7-Dec-16 15:29pm    
"If your friend is not on the same network then you will have to allow access from the internet to your PC, usually via a VPN."

He's not on the same network so he will not be able to connect to the localhost.
https://i.imgur.com/rXkTrtu.png where I added "MyIPV4" what do I add there? Because the IP I put in there is the IP I connect to through Visual Studio.
Also.. I need to portforward the port "3306" right?
Michael_Davies 7-Dec-16 16:17pm    
Do you have a VPN set up? Can you friend see your PC from the internet?

You'll need to set up remote access to your PC first to allow access from the internet, once you have that set up you can share the details with your friend and he can then see your PC's IP and use that to access MySQL.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900