Connect MySQL under Mono

Source: Internet
Author: User

Reference article: http://www.cnblogs.com/24la/p/mysqldatadll.html

mono3.6.0+jexus5.6.1, operating system centOS6.5

Download install. NET MySQL connection component, get MySql.Data.dll my version is 6.7.4.0

Referencing in Web projects

To add a configuration in the Database Connection configuration section

<add name= "Mysqlconn" connectionstring= "server=192.168.79.135;database=monotest; Uid=root; pwd=123456; Charset=utf8 "providername=" MySql.Data.MySqlClient "/>

Note: My MySQL database character encoding is UTF8, here the connection string also specifies the character encoding to UTF8, lest Chinese characters garbled

Web. config adds configuration section when deploying to CentOS

<system.data>
<DbProviderFactories>
<add name= "MySQL Data Provider" invariant= "MySql.Data.MySqlClient"
Description= ". Net Framework Data Provider for MySQL"
Type= "Mysql.data.mysqlclient.mysqlclientfactory,mysql.data,
version=6.7.4.0, culture=neutral, publickeytoken=c5687fc88969c44d "/>
</DbProviderFactories>
</system.data>

Note that the MySql.Data.MySqlClient version changes according to its own situation

Page Chinese garbled processing, Web. config add a straight section

<globalization requestencoding= "gb2312" responseencoding= "gb2312" culture= "ZH-CN" uiculture= "ZH-CN"/>

The database establishes the test data table, carries on the test

Connect MySQL under Mono

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.