I'm trying to connect MySQL Server 8.0 running on windows to C#. Before this, I was using PhpMyAdmin but now I've installed MySql 8.0 Command Line Client and I want to connect my program with it. It is running on port 2208 as port 3306 was already in use.
I've tried to search internet for solution but all the solution that appears are connecting MySQL with PhpMyAdmin.
server = "localhost:2208";
database = "LoginFormApplication";
uid = "root";
password = "";
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
Debug.WriteLine(connectionString);
connection = new MySqlConnection(connectionString);
OpenConnection(); //connecting to database
I'm looking to connect to MySQL server running on windows machine to C#. But it throws error even though the server is still running. Below are the errors:
1. Connection must be open and valid
2. Unable to connect to any of the specified MySQL hosts
3. Exception thrown: 'MySql.Data.MySqlClient.MySqlException' in MySql.Data.dll
4. Exception thrown: 'System.InvalidOperationException' in MySql.Data.dll
Open Connection Method:
connection.Open();