标签:dba class mysql基本操作 用户 thread 选择 sql man cti
1.在管理NuGet程序包中,选择浏览,下载MySql.Data,
2.在命名空间中引用
using MySql.Data.MySqlClient;
3.配置Configuration文件连接Mysql
<?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name="connStr" connectionString="server=255.255.255.255;port=3306;database=dbase;user=root;password=psd" providerName="System.Data.SqlClient"/> </connectionStrings> </configuration>
用法
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using MySql.Data.MySqlClient; namespace W数组 { class Sqlhelper { /// <summary> /// 服务器地址;端口号;数据库;用户名;密码 /// </summary> public static string connectStr = System.Configuration.ConfigurationManager.ConnectionStrings["connStr"].ConnectionString; //用户名和密码在MySQL定义的 public static MySqlConnection conn = new MySqlConnection(connectStr); //using MySql.Data.MySqlClient; } }
标签:dba class mysql基本操作 用户 thread 选择 sql man cti
原文地址:https://www.cnblogs.com/shyw/p/12106249.html