在C#中通过CMD命令调用mysq批处理命令的一些总结

1,连接mysql数据库管理器: 
Code
2,插入数据:
Code
3,执行脚本文件:
string sentence = string.Format("mysql.exe -h{0} -u{1} -p{2} -f<\"{3}\"", EditConfig.Ip, EditConfig.DBId, EditConfig.DBPwd, path);

4,获取mysql的获取数据库中的所有表和视图名(在mysql.data.dll):
      show tables
5, 获取mysql数据库中当前表的所有字段名(在mysql.data.dll):

string sql = string.Format("select COLUMN_NAME from information_schema.columns where table_name='{0}'", editTableName);

6,mysql根据表名添加字段(在mysql.data.dll):

string sql = string.Format("alter table {0} add column {1} {2}({3})", editTableName,filedName,filedType,Convert.ToInt32( filedSize));

7,导出mysql数据库icms的数据:
//--注释:--default-character-set=gb2312 为数据库默认编码设置;--opt为快速执行选项;--hex-blob为导出
二进制;--single-transaction 为(可重复执行)-不准确;--compatible=mysql323,mysql40 为兼容的数据库版本;
 -R 为导出数据库中所有的存储过程和函数;  下面的strimportList是导出数据库中的视图和表名字的集合

Code

8,导入mysql数据库icms的数据:

Code
原文地址:https://www.cnblogs.com/tangtang615/p/1545843.html