Use the correct connection string for MySQL connector net connection to MySQL

Source: Internet
Author: User
When you use myodbc or mysqldrivercs to connect to the MySQL database for MySQL connector net to use the correct connection string, you only need to enter the Database Host address, database name, database access account, and database access password.

However, this is not the case with MySQL connector net.

When using the "host = localhost; database = test; uid = root; Pwd =;" string to connect to MySQL, the Chinese characters saved to the database always become similar ??? That meike Xingwen. Puzzled, it is suspected that MySQL 4.1.x uses the UTF-8 character set to save the data problem, so in exchange for MySQL 4.0.22. Try again. the problem persists. It seems that the problem lies in MySQL connector net. Open the MySQL connector net help, go to the mysqlconnection section, and find the answer line by line. The result shows that there is a charset-or character set parameter in the parameter list. Parameters are described as follows:

Specifies the character set that shoshould be used to encode all queries sent to the server. resultsets are still returned in the character set of the data returned.

It turns out that ......

Change the connection string to "host = localhost; database = test; uid = root; Pwd =; charset = gb2312" and try again. OK. Everything is normal now!

PS: when accessing MySQL 4.1.x using the new phpMyAdmin version, a connection character set is displayed. At that time, I changed my mind and found that there was no change (because the accessed database, data tables, and fields were both in English-_-|. Now think about it, it should be something like this charset parameter.

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.