Use Mono to connect to the MySQL database on Linux

Source: Internet
Author: User

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:

 
 
  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 () 

After finding a foreign forum, I got the following prompt:

 
 
  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. 

As prompted

 
 
  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 

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.