简体   繁体   English

如何使用 C# 连接到 MySQL 服务器?

[英]How to connect to a MySQL server using C#?

I have a C# Application which would access a MySQL server on another computer.我有一个 C# 应用程序,它可以访问另一台计算机上的 MySQL 服务器。 I am trying to do it via IP.我正在尝试通过 IP 来实现。 Here is my Connection String :这是我的连接字符串:

result = "server =66.45.233.226; user id=testcampuscrm; password =Daph$5656; database=testcampuscrm; convert zero datetime=true; ";

getting error this得到错误这个

Access denied for user 'testcampuscrm'@'66.45.232.178' (using password: YES)用户“testcampuscrm”@“66.45.232.178”的访问被拒绝(使用密码:是)

My code is anther hosting and mysql database anther hostig please help us.我的代码是花药托管和 mysql 数据库花药 hostig 请帮助我们。 Thanks谢谢

There is multiple things you have to take into consideration while accessing mysql from another machine some them are -从另一台机器访问 mysql 时,您必须考虑多种因素,其中一些是 -

Assuming you did write correct code假设您确实编写了正确的代码

1.Change mysql config (my.ini) to receive packets from all IP 1.更改mysql配置(my.ini)以接收来自所有IP的数据包

2.Add firewall Exception for port 3306 on machine where Mysql is Hosted 2.为托管Mysql的机器上的端口3306添加防火墙例外

3.User name password is Correct and granted proper privileges. 3.用户名密码正确并被授予适当的权限。

PS:-Do not share server credentials on public forums PS:-不要在公共论坛上共享服务器凭据

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

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