I am creating website in ASP.NET Core 2.0 and now I need to get data from my mysql database.
Database is located on hosting which use cpanel
In past I have created simple REST API which get some data from that database and it used this config:
server: db5.cpanelhosting.rs
Port: 3306
user: termodom_guest
pw: a1s2d3f4g5h6j7k8
Now problem is when I use code like this:
using (MySqlConnection con = new MySqlConnection("server=217.26.215.19;port=3306;database=termodom_TDMajstor;user=termodom_guest;password=a1s2d3f4g5h6j7k8"))
{
con.Open();
using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM KORISNIK", con))
{
MySqlDataReader dr = cmd.ExecuteReader();
if(dr.Read())
{
return true;
}
}
}
It drops me error
MySql.Data.MySqlClient.MySqlException (0x80004005): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at MySql.Data.Common.StreamCreator.GetTcpStream(MySqlConnectionStringBuilder settings) at MySql.Data.MySqlClient.NativeDriver.Open().
I have also tried online testing connection but it also cannot connect. What to do?