简体   繁体   中英

Can not connect to MySQL with VS2012

I am trying to establish connection between my application in C# and MySQL. I have downloaded .NET connector from MySql website. I have installed MySQL server with TYPO3 winstaller, and it is running properly.

Here is my code:

 MySqlConnection con = new MySqlConnection("Server=localhost:8501;Database=drogy;Uid=root;Pwd=;");
 con.Open();

It says that: Unable to connect to any of the specified MySQL hosts.

In PHPMyAdmin I see host as localhost:8501. I am sure that user root has password set to NO and I am also pretty sure about the database name. How can I do this please? Thank you

  1. you should not mention the password if maybe its should be empty means use the ' ' single quotes in you code.

  2. And you should remove the ; in after the password like ot;Pwd=;"); you should change like ot;Pwd=");

  3. if your not add the connector, first of all you should must add the MySQL Connector .

sample code:

"server=localhost:portno; user id=yourusername; password=yourpassword; database=yourdatabasename"

update:1

All had happend after moving database files to new location and after updating mysql server. All tables with InnoDB engine disappeared from my database. I was trying to recreate them, but mysql told me 1146: Table 'xxx' doesn't exist all the time until I had recreated my database and restarted mysql service .

I think there's a need to read about InnoDB table binaries.

click here : 1

* Pwd =;“ *必需的数据库密码在“密码”字段中输入密码并尝试使用它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM