In my project, the Connect database statement is written in the configuration file:
<add key= "ConnectionString" value= "database= ' testdata ';D ata source= ' localhost '; port= ' 3306 '; User id= ' root '; password= ' root '; charset= ' UTF8 '; Treattinyasboolean=false "/>
where database is the name, data source is the server address where the database resides, "localhost" represents the local address, and port is the port number of the MySQL database the user ID represents the username password on behalf of the user password. The CharSet table requests the character set used by the server to connect, by default: None because Chinese is present in the database in the project, the different character sets of MySQL are not identical to the recognition in both Chinese and English. The use of UTF8 can ensure that there is no Chinese garbled phenomenon.
At the same time the database base character set is "UTF8", the database collation is "UTF8_GENERAL_CI";
. NET connection MySQL database statements