Hello everyone! Im trying to make plugin for my server within C#, but i meet problems with connecting to my DB. I tried to make connection with MySql.Data.MySqlClient with no luck. Im figured up that problem starts when i’m trying to establish connection to DB with new MySqlConnection.Open() and there is no luck. Im attaching screenshot with server error. I will be appreciated for any help.
You might wanna share your code.
MySql.Data.MySqlClient.MySqlConnection conn;
string myConnectionString;
myConnectionString = "server=127.0.0.1;uid=root;" +
"pwd=1337;database=minotaur";
try
{
conn = new MySql.Data.MySqlClient.MySqlConnection(myConnectionString);
conn.Open();
}
catch (MySql.Data.MySqlClient.MySqlException ex)
{
switch (ex.Number)
{
case 0:
Debug.WriteLine("Cannot connect to server. Contact administrator");
break;
case 1045:
Debug.WriteLine("Invalid username/password, please try again");
break;
}
}
Thank you for your reply. Here is my code.
anders
4
You don’t have a port in your connection string.
Thank you for your reply. Adding port at the connection string seems changes nothing. Im also can’t see port setting at the offical doc’s like this.
d0p3t
6
I would suggest using the mysqlconnector. Use the dll that comes with GHMatti’s stripped version (see his Github) as it has SSL/TLS stripped from it. FiveM’s mono on Windows does not contain this functionality.
To get an idea of how to use this connector you can consult the mysqlconnector documentation or look at GHMatti’s mysql resource.
Using GHMatti’s resources solve troubles. Thank you d0p3t and everyone who reply this topic!
1 Like