用Mono來連接MySQL數(shù)據(jù)庫在Linux上
此文章主要向大家描述的是在Linux上使用Mono來連接MySQL數(shù)據(jù)庫的一大絕招,我們大家都知道連接MySQL數(shù)據(jù)庫在實際應(yīng)用中是經(jīng)常出現(xiàn)的,所以很多人對其也是備受關(guān)注的。其具體內(nèi)容參考的例子可以再相關(guān)網(wǎng)站上查詢。
特別提出來的是我***次編譯運行的時候出現(xiàn)這樣的錯誤提示:
- 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.
根據(jù)提示我把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服務(wù)器程序sudo /etc/init.d/mysql restart就可以正常連接查詢了。以上的相關(guān)內(nèi)容就是對在Linux上使用Mono連接MySQL數(shù)據(jù)庫的介紹,望你能有所收獲。
上述的相關(guān)內(nèi)容就是對在Linux上使用Mono連接MySQL數(shù)據(jù)庫的描述,希望會給你帶來一些幫助在此方面。
【編輯推薦】
- MySQL數(shù)據(jù)庫中最基本的函數(shù)類型
- MySQL數(shù)據(jù)庫中的字符串
- MySQL數(shù)據(jù)庫權(quán)限設(shè)置的實際運行過程
- MySQL 分頁存儲過程的實際操作流程與代碼
- MySQL_fetch_row() 和 MySQL_fetch_array() 的差異