C#操作mysql数据库 unable to connect to any of the specified mysql hosts
来源:互联网 发布:c语言开发实战宝典pdf 编辑:程序博客网 时间:2024/04/30 21:09
最近打开之前开发的项目,可是连登陆不行,报错如下,我也是醉了,不知道什么原因。
开始就度娘,输入错误信息,有人说是防火墙的问题,有的说服务没有开启,等等办法。我一一试了试都不能解决我的问题,我的连接字符串为:
string M_str_sqlcon = "server=localhost;user id=root;password=root;database=ietm;pooling=true;CharSet=utf8;port=3306"; 。
无意间得到灵感,之前我为了翻墙,下载了hosts文件覆盖了C:\Windows\System32\drivers\etc里边的文件,导致localhost不能映射到本地,所以连接字符串用localhost就不能打开数据库连接。
解决办法使用127.0.0.1而不是localhost,以后不管是何种数据库开发,当数据库是本机时,一定要用127.0.0.1,否则一不小心就不能连接数据库了,而且你还不知道哪里错了。
说一下为什么我很长时间才解决这个问题,因为我以为我什么都没改,代码怎么就不能用了呢,我猜是不是mysql版本的问题呢,虽然我不认识是,但是我还是试了一下,卸载了、安装,卸载、安装,把5.1各个版本都试了一遍,还是没能解决问题。最后竟然问题在localhost这。
说一下,只能怪自己遇到的问题太少了,缺乏经验。
0 0
- C#操作mysql数据库 unable to connect to any of the specified mysql hosts
- Unable to connect to any of the specified MySQL hosts.
- Unable to connect to any of the specified MySQL hosts.
- mysql MySql Login Unable to connect to any of the specified MySQL hosts
- .net连接MySql:Unable to connect to any of the specified MySQL hosts
- Visual Studio 2010--报错mysql:Unable to connect to any of the specified MySQL hosts
- VS连接MySQL·:Unable to connect to any of the specified MySQL hosts(VS连接MySQL出错)
- Unable to connect to any hosts due to exception: java.net.ConnectException:...问题的解决
- Unable to connect to specified host. 错误
- Unable to locate any of the following operational binaries 解决方法
- How to Connect to MySQL Using C#
- Could Not Connect To The Specified Instance - MySQL Error Number 2003 - (10061)问题
- Failed to connect to the session manager: None of the authentication protocols specified are support
- Is there any best way to reduce the size of ibdata in mysql.?
- 装mysql时,报unable to find a version of the runtime to run this application
- 安装mysql时,报“unable to find a version of the runtime to run this application ”
- Unable to locate JAR/zip in file system as specified by the driver definition: mysql-connector-java-
- Java - Connect to mysql
- iOS之Cell工厂解决多种cell的困扰
- NetMQ 测试用例
- Linux安装Mysql - 解决Access denied for user ''@'localhost' to database 'mysql'问题
- 学习Android从0开始之基础篇(5)- Button简介
- 无关学术
- C#操作mysql数据库 unable to connect to any of the specified mysql hosts
- Git命令总结
- 从iTunes中下载手机应用,并获取应用图标
- C语言中,头文件和源文件的关系(转)
- samba 配置
- JavaSE008_循环结构之return
- Android View绘制流程
- C++文件操作典型案例
- Ubuntu 15.10下安装broadcom无线网卡驱动