Trouble connecting to MySQL database form a seperate computer

I'm learning C# by making my own Chat app. And I want to use a database (MySQL) for storing usernames and passwords (IK not safe maybe). But i'm having trouble connecting to it. Any idea why?
No description
36 Replies
cap5lut
cap5lut2w ago
whats the specific error u r getting, connection refused?
Angius
Angius2w ago
Also, where's the database, exactly? Another PC on the same LAN? another PC on a different network? Something else?
K4ЯNXGEx333彡
I'm on a seperate wifi connection. DB is on a VPS
cap5lut
cap5lut2w ago
so its on the internet, u should first of all set a good password for the root, and also create an limited account (with a good password) for that one scheme to plug that big fat security hole u have there an which line of code the exception is thrown?
K4ЯNXGEx333彡
It's not within my code but from something else. Imma take a little break real quick. Just to clear my mind
cap5lut
cap5lut2w ago
the stacktrace of Inner Exception 1: MySqlException is the interesting part here
K4ЯNXGEx333彡
Alright hold on. Give me like 5 mins And I'll come back it look into it
cap5lut
cap5lut2w ago
kk then i take a quick ciggy break back
K4ЯNXGEx333彡
I'm back
cap5lut
cap5lut2w ago
⤴️
K4ЯNXGEx333彡
I think this is from me doing the connection wrong Inner Exception 1: MySqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
cap5lut
cap5lut2w ago
well, thats why i asked for the stacktrace, the error message i can read already
K4ЯNXGEx333彡
Call Stack?
cap5lut
cap5lut2w ago
thats the call stack/stacktrace from the outer exception (the AggregateException), i need the one from the inner MySqlException
K4ЯNXGEx333彡
How would I find that?
cap5lut
cap5lut2w ago
while the execution is paused on
No description
cap5lut
cap5lut2w ago
u can inspect the locals, that includes the exceptionList, the first element should be the MySqlException that should have a StackTrace property (the string content will look a bit weird with \n in there, just copy that all and paste it here)
K4ЯNXGEx333彡
Yeah I sent the screenshots Here
cap5lut
cap5lut2w ago
yeah and thats not showing the stacktrace... gimme a sec to prepare a screenshot
cap5lut
cap5lut2w ago
that one is what im talking about
No description
K4ЯNXGEx333彡
Ok well I'm not getting that anymore. I'm now getting this
No description
cap5lut
cap5lut2w ago
actually if ya click on View Details u should be able to see a similar window
No description
cap5lut
cap5lut2w ago
guess ur db isnt reachable from the outside
K4ЯNXGEx333彡
Well I did it b4 in Node.js I think
cap5lut
cap5lut2w ago
was that from ur local machine or from the vps?
K4ЯNXGEx333彡
VPS
cap5lut
cap5lut2w ago
yeah and now u r running from local machine right? usually dbs are configured to only listen for connections on the local machine they r running on, in this case the vps and not ur machine
K4ЯNXGEx333彡
So that means I would have to have a server in my house? Bc if so I can bring out an old laptop But that would cause security risks
cap5lut
cap5lut2w ago
well, unless u run the db on the same machine as ur application u will have that risk. a machine in ur local network would be safer tho because not the whole internet could try to connect to it
K4ЯNXGEx333彡
Ok I'll do that then
cap5lut
cap5lut2w ago
so i would go for the route: - set up that old laptop in ur local network - install mysql and give root a proper password - create a schema for ur application - create a user that has only access to that schema and has another proper password - configure the mysql server to listen on any ip, not just localhost (which is the default) and then u should be able to use it the mysql root user should stay to only be able to login from localhost (u can set up ssh to log into it if required, passkeys are more secure anyway) the mysql user for that one schema can be set up to be able to log in from any ip, this is then also the one u will be using for ur application
K4ЯNXGEx333彡
Ok I just setup my laptop and xampp (MySQL) server. and still failed I'm still looking on the internet for a solution
cap5lut
cap5lut2w ago
as said u still have to configure mysql to listen on any ip instead of just localhost
K4ЯNXGEx333彡
I did it. Whole time I was using public IP Finally Well it only works if I'm a VPN. Gotta do some more testing and coding