赞
踩
- public static bool BackUp() {
- DataRow dataRow = package.sql("select * from t_config where name='sql_balance'", package.sql_connection.conf).Tables[0].Rows[0];
- string server = "127.0.0.1";//服务器地址
- string user_id = "root";//用户名
- string password = "root";//密码
- string database = "FanLai";//数据库名称
- string backupsql = string.Format("mysqldump --host={0} --default-character-set=utf8 --lock-tables --routines --force --port=3306 --user={1} --password={2} --quick ", server, user_id,password);
- //mysqldump的路径
- string mysqldump = @"C:\Program Files\MySQL\MySQL Server 8.0\bin";
- //备份数据库的路径
- string strDBpath = @"D:\mysql";
- if (!Directory.Exists(strDBpath))
- {
- Directory.CreateDirectory(strDBpath);
- }
-
- //备份数据库
- if (!string.IsNullOrEmpty(database))
- {
- string filePath = strDBpath + DateTime.Now.ToString("yyyyMMdd_HHmmss") + database + ".sql";
- string cmd = backupsql + database + " >" + filePath;
- string result = RunCmd(mysqldump, cmd);
- return true;
- }
- return false;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。