用Mono来连接MySQL数据库在Linux上

此文章主要向大家描述的是在Linux上使用Mono来连接MySQL数据库的一大绝招,我们大家都知道连接MySQL数据库在实际应用中是经常出现的,所以很多人对其也是备受关注的。其具体内容参考的例子可以再相关网站上查询。

特别提出来的是我***次编译运行的时候出现这样的错误提示:

  1. MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts  
  2. in <0x006c5> MySql.Data.MySqlClient.NativeDriver:Open ()  
  3. in <0x00027> MySql.Data.MySqlClient.Driver:Create (MySql.Data.MySqlClient.MySqlConnectionString settings)  
  4. in <0x0008d> MySql.Data.MySqlClient.MySqlPool:CreateNewPooledConnection ()  
  5. in <0x001b0> MySql.Data.MySqlClient.MySqlPool:GetPooledConnection ()  
  6. in <0x0003f> MySql.Data.MySqlClient.MySqlPool:GetConnection ()  
  7. in <0x000e5> MySql.Data.MySqlClient.MySqlPoolManager:GetConnection (MySql.Data.MySqlClient.MySqlConnectionString settings)  
  8. in <0x00050> MySql.Data.MySqlClient.MySqlConnection:Open () 

不思不得其解,后来找到一个国外的论坛,得到这样的提示:

  1. The most likely cause of this is that MySQL is not configured to accept tcp/ip connections.  
  2. See here http://dev.mysql.com/doc/mysql/en/can-not-connect-to-server.html  
  3. make sure your /etc/mysql/my.cnf file does not have the "skip-networking" 
  4. feature enabled. This is the default in some installations and disables tcp/ip connections. 

根据提示我把my.cnf中的

  1. # Instead of skip-networking the default is now to listen only on  
  2. # localhost which is more compatible and is not less secure.  
  3. #bind-address = 172.22.60.126 

bind-address注释掉,然后重新启动mysql服务器程序sudo /etc/init.d/mysql restart就可以正常连接查询了。以上的相关内容就是对在Linux上使用Mono连接MySQL数据库的介绍,望你能有所收获。

 

上述的相关内容就是对在Linux上使用Mono连接MySQL数据库的描述,希望会给你带来一些帮助在此方面。

【编辑推荐】

  1. MySQL数据库中最基本的函数类型
  2. MySQL数据库中的字符串
  3. MySQL数据库权限设置的实际运行过程
  4. MySQL 分页存储过程的实际操作流程与代码
  5. MySQL_fetch_row() 和 MySQL_fetch_array() 的差异

 

文章来源网络,作者:管理,如若转载,请注明出处:https://shuyeidc.com/wp/248185.html<

(0)
管理的头像管理
上一篇2025-04-27 11:26
下一篇 2025-04-27 11:27

相关推荐

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注