时间:2021-07-01 10:21:17 帮助过:2人阅读
mysql的下载安装可参考此博客很详细:https://www.cnblogs.com/xiongzaiqiren/p/8970203.html
完成后采用工具端: Nvicat(mysql的一个可视化工具网上有下载的无需安装打开即可用) 着个在查询时可以正常执行但是总是会报错:
[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ‘information_schema.PROFILING.SEQ‘ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
执行如下信息后恢复:
set sql_mode = ‘‘;
set sql_mode = ‘NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES‘;
对与C#连接需要下载MySql.data.dll 并引用后,需要 using MySql.Data.MySqlClient;
操作连接非常类似于连接sqlserver,代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
namespace my_sql_demo
{
class Program
{
static void Main(string[] args)
{
string str = "data source=127.0.0.1;initial catalog=mysql;user id=sa;password=Syfjc021;port=3306";
//string str = "host=127.0.0.1;user id=sa;password=Syfjc021;database=mysql";
MySqlConnection con = new MySqlConnection(str);
string sql_select = " select * from test_table; ";
string sql_insert = " insert into test_table(ruid,emp_no,emp_name)values(1,‘ss‘,‘cxq‘); ";
string sql_update = " update test_table set emp_no=‘shanbei‘ where ruid =1; ";
string sql_delte = " delete from test_table where ruid=1; ";
con.Open();
//select
for (int i = 0; i < 4; i++)
{
string sql = string.Empty;
switch (i)
{
case 0:
sql = sql_select;
break;
case 1:
sql = sql_insert;
break;
case 2:
sql = sql_update;
break;
case 3:
sql = sql_delte;
break;
default:
break;
}
using (MySqlCommand cmd = new MySqlCommand(sql_select, con))
{
if (con.State != System.Data.ConnectionState.Open)
{
con.Open();
}
MySqlCommand cmd_exe = new MySqlCommand(sql, con);
cmd_exe.CommandType = System.Data.CommandType.Text;
cmd_exe.ExecuteScalar();
MySqlDataAdapter mda = new MySqlDataAdapter(cmd);
System.Data.DataTable dt = new System.Data.DataTable("data");
mda.Fill(dt);
if (dt != null && dt.Rows.Count > 0)
{
foreach (System.Data.DataRow item in dt.Rows)
{
Console.WriteLine("{0}---{1}---{2}---{3}", item["ruid"], item["emp_no"], item["emp_name"],sql);
}
}
else
{
Console.WriteLine("null or o rows--->" + sql);
}
}
}
Console.ReadKey();
}
}
}
mysql_demo
标签:form gen val base type ati mysqld ble lda