简体   繁体   English

使用C#与Amazon EC2中的MySQL进行桌面连接(操作方法)

[英]Desktop connection to MySQL in Amazon EC2 using C# (How To)

In my desktop application I need to connect to MySQL database in Amazon EC2. 在我的桌面应用程序中,我需要连接到Amazon EC2中的MySQL数据库。 I tried to built the connection string but am very confused as to what parameters I need to include and how the connection string should look like and what commands need to call. 我尝试构建连接字符串,但是对于我需要包括哪些参数以及连接字符串的外观以及需要调用哪些命令感到非常困惑。 Can anyone experience in this provide me with sample listings so that I can follow? 有人可以向我提供示例清单,以便我可以关注吗? Your help is very much appreciated. 非常感激你的帮助。

Information I have on EC2 which I use to connect successfully using Workbench: 我拥有有关EC2的信息,可用于通过Workbench成功连接:

  • SSH Hostname SSH主机名
  • SSH Username SSH用户名
  • SSH Key File (reside in my PC) SSH密钥文件(驻留在我的PC中)
  • MySQL Hostname (ie 127.0.0.1) MySQL主机名(即127.0.0.1)
  • MySQL Server Port (ie 3306) MySQL服务器端口(即3306)
  • Userpassword 用户密码

After some research over the internet, I have found the answer to this seemingly simple question. 经过互联网研究后,我找到了这个看似简单的问题的答案。 All I need to do really is add in MySQL /net connector in the project and referenced it. 我真正需要做的就是在项目中的MySQL / net连接器中添加并引用它。 Then I used the follwoing connecting string:- 然后我使用了以下连接字符串:-

eg: myConnStr = "host=ec2-xxx-xx-xx-xxx.compute-1.amazonaws.com" + ";Port=3306;UserName=your_db_username" + ";Password=your_db_password;Database=your_db;"; 例如:myConnStr =“ host = ec2-xxx-xx-xx-xxx-xxx.compute-1.amazonaws.com” +“; Port = 3306; UserName = your_db_username” +“; Password = your_db_password; Database = your_db;”;

Thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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