我无法从C#访问mysql数据库 [英] i can't access to mysql database from c#

查看:160
本文介绍了我无法从C#访问mysql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,并在它的phpmyadmin中创建一个数据库,我想从c#连接到它.

i have a web site and in it's phpmyadmin create a database and i want to connect to it from c#.

我在Visual Studio 2010中使用MySQL connector for .NET.

i use MySQL connector for .NET in visual studio 2010.

我的String Connection是:

 server=158.58.185.197;database=porbarco_base;uid=****;pwd=****;CharSet=utf8;

但是我无法连接到数据库并给出错误:Unable to connect to any of the specified MySQL hosts.

but i can't connect to database and give an error : Unable to connect to any of the specified MySQL hosts.

我如何连接到该数据库.

How i can connect to this database.

我在stackoverflow中看到很多线程,但是不能解决我的问题.

i see many threads in stackoverflow but don't solve my problem.

推荐答案

可能性很可能是问题出在您的C#较少,而对MySQL的远程访问更多

The likelyhood is that the problem is less your C# and more remote access to MySQL

您需要检查以下内容.

  1. MySQL是否正在监听网络地址.检查您的mysql配置文件.查找bind address的条目.如果将其设置为127.0.0.1,则您只是在本地主机上侦听,请将其更改为0.0.0.0,并记住重新启动服务

  1. Is MySQL listening a network address. Check your mysql configuration file. Look for an entry for bind address. if its set to 127.0.0.1 then you are just listening on localhost, change it to 0.0.0.0 and remember to restart the service

您的Linux防火墙是否阻止了对mysql端口的远程访问.

Is your linux firewall blocking remote access to the mysql port.

您的mysql是否允许从远程主机对指定用户进行远程访问.参见此链接有关如何进行设置的示例

Does your mysql allow remote access for the specified user from a remote host. see This link for an example of how to set this up

这篇关于我无法从C#访问mysql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆