此文章主要向大家描述的是在Linux上使用Mono来连接MySQL数据库的一大绝招,我们大家都知道连接MySQL数据库在实际应用中是经常出现的,所以很多人对其也是备受关注的。其具体内容参考的例子可以再相关网站上查询。
特别提出来的是我第一次编译运行的时候出现这样的错误提示:
MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts in <0x006c5> MySql.Data.MySqlClient.NativeDriver:Open () in <0x00027> MySql.Data.MySqlClient.Driver:Create (MySql.Data.MySqlClient.MySqlConnectionString settings) in <0x0008d> MySql.Data.MySqlClient.MySqlPool:CreateNewPooledConnection () in <0x001b0> MySql.Data.MySqlClient.MySqlPool:GetPooledConnection () in <0x0003f> MySql.Data.MySqlClient.MySqlPool:GetConnection () in <0x000e5> MySql.Data.MySqlClient.MySqlPoolManager:GetConnection (MySql.Data.MySqlClient.MySqlConnectionString settings) in <0x00050> MySql.Data.MySqlClient.MySqlConnection:Open ()
不思不得其解,后来找到一个国外的论坛,得到这样的提示:
The most likely cause of this is that MySQL is not configured to accept tcp/ip connections. See here http://dev.mysql.com/doc/mysql/en/can-not-connect-to-server.html make sure your /etc/mysql/my.cnf file does not have the "skip-networking" feature enabled. This is the default in some installations and disables tcp/ip connections.
根据提示我把my.cnf中的
# Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. #bind-address = 172.22.60.126
bind-address注释掉,然后重新启动mysql服务器程序sudo /etc/init.d/mysql restart就可以正常连接查询了。上面说了这么多内容,是关于对在Linux上使用Mono连接MySQL数据库的介绍,不知道各位对MySQL的认识是不是更上一层楼了,时时关注ITJS,学习最新Mysql技术。
上述的相关内容就是对在Linux上使用Mono连接MySQL数据库的描述,IT技术网itjs.cn整理分享给学习MySQL的朋友,希望大家喜欢这样的Mysql文章或资料。