This article mainly describes how to use Mono on Linux to connect to the MySQL database. We all know that connection to the MySQL database often occurs in practical applications, therefore, many people are also highly concerned about it. For details, refer to the example on the relevant website.
In particular, this error message is prompted during the first compilation and running:
- 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 ()
After finding a foreign forum, I got the following prompt:
- 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.
As prompted
- # 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
Comment out bind-address and restart the mysql server program sudo/etc/init. d/mysql restart to query the connection normally. The above content is an introduction to using Mono to connect to the MySQL database on Linux. I hope you will have some gains.
The above content describes how to use Mono to connect to the MySQL database on Linux. I hope it will help you in this regard.