MySql Server安装步骤

1安装MySql Server

2 安装MySqlServer管理工具

解压中文语言包,将文件复制到安装目录下覆盖

文件覆盖后,打开软件设置语言为中文(CN)

3 MySqlServer开发注意事项(C#)

  1. 联接字符串:"Server=localhost;Database=100;Uid=root;Pwd='root'"
  2. 引用MySql.Data.dll;
  3. using MySql.Data.MySqlClient;
  4. 使用MySqlConnection、MySqlParameter、MySqlDataAdapter、MySqlCommandBuilder、MySqlCommand、MySqlDataAdapter、MySqlTransaction等类
  5. 使用MySqlCommand. ExecuteScalar()方法返回的object如果要转为int类型,必须使用Convert来强制转换,否则可能会出错。
  6. 修改记录时,字段数据类型如果为Bit类型的时候,Sql语句中的字段值要使用Ture或False,不能像SqlServer中一样使用0或1。
  7. 命令行工具:

public class Cmd

{

/// <summary>

/// 执行Cmd命令

/// </summary>

/// <param name="workingDirectory">要启动的进程的目录</param>

/// <param name="command">要执行的命令</param>

public static void StartCmd(String workingDirectory, String command)

{

Process p = new Process();

p.StartInfo.FileName = "cmd.exe";

p.StartInfo.WorkingDirectory = workingDirectory;

p.StartInfo.UseShellExecute = false;

p.StartInfo.RedirectStandardInput = true;

p.StartInfo.RedirectStandardOutput = true;

p.StartInfo.RedirectStandardError = true;

p.StartInfo.CreateNoWindow = true;

p.Start();

p.StandardInput.WriteLine(command);

Thread.Sleep(10000);

//p.StandardInput.WriteLine("exit");

}

public static void StartCmd()

{

Process p = new Process();

p.StartInfo.FileName = "cmd.exe";

p.StartInfo.UseShellExecute = false;

p.StartInfo.RedirectStandardInput = true;

p.StartInfo.RedirectStandardOutput = true;

p.StartInfo.RedirectStandardError = true;

p.StartInfo.CreateNoWindow = true;

p.Start();

p.StandardInput.WriteLine("net stop mysql");

Thread.Sleep(5000);

p.StandardInput.WriteLine("net start mysql");

Thread.Sleep(5000);

p.StandardInput.WriteLine("exit");

}

}

  1. 备份:

public static bool BackUp(string backupPath)

{

try

{

//构建执行的命令

StringBuilder sbcommand = new StringBuilder();

sbcommand.AppendFormat("mysqldump -f -l -q -uroot -proot Sciendox50 -r \"{0}\"", backupPath);

String command = sbcommand.ToString();

//获取mysqldump.exe所在路径

String appDirecroty = @"C:\Program Files\MySQL\MySQL Server 5.5\bin\";

Cmd.StartCmd(appDirecroty, command);

Cmd.StartCmd();//重启mysql服务

MessageBox.Show(@"数据库已成功备份到 " + backupPath + " 文件中", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

return true;

}

catch (Exception)

{

MessageBox.Show("数据库备份失败!");

return false;

}

}

  1. 还原:

/// <summary>

/// 数据还原

/// </summary>

/// <param name="FilePath">文件路径</param>

/// <returns></returns>

public static bool RestoreDB(string FilePath)

{

try

{

StringBuilder sbcommand = new StringBuilder();

//在文件路径后面加上""避免空格出现异常

sbcommand.AppendFormat("mysql -uroot -proot Sciendox50 <\"{0}\"", FilePath);

String command = sbcommand.ToString();

//获取mysql.exe所在路径

String appDirecroty = @"C:\Program Files\MySQL\MySQL Server 5.5\bin\";

DialogResult result = MessageBox.Show("您是否真的想覆盖以前的数据库吗?那么以前的数据库数据将丢失!!!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

if (result == DialogResult.Yes)

{

Cmd.StartCmd(appDirecroty, command);

Cmd.StartCmd();//重启mysql服务

MessageBox.Show("数据库还原成功!");

return true;

}

return false;

}

catch (Exception)

{

MessageBox.Show("数据库还原失败!");

return false;

}

}

MySql安装方法和配置、解决中文乱码的更多相关文章

  1. springmvc:配置解决中文乱码的过滤器

    在web.xml中配置以下内容: <!--配置解决中文乱码过滤器--> <filter> <filter-name>characterEncodingFilter& ...

  2. linux安装openoffice,并解决中文乱码

    1.安装openoffice 官网http://www.openoffice.org/zh-cn/download/下载 2.解压并进入文件夹: cd /zh-cn/RPMS yum localins ...

  3. python 之路初(一):pycharm 安装 和 环境配置 和 中文乱码问题

    从健身和学习中我一体会到坚持的力量.想写写东西的想法已经好久了,就是不知道怎么开始.最近生活开始给我各种攻击和磨练,我从声嘶力竭到沉默到默默坚持自己,改变自己并总结告诉自己:少说多看,看破不说破,宁愿 ...

  4. 阶段3 3.SpringMVC·_02.参数绑定及自定义类型转换_3 配置解决中文乱码的过滤器

    输入中文 中文后台接收到 全部乱码 springMvc提供了过滤器 配置过滤器 characterEncodingFilter是首字母小写当做起的名称.当然这里也可以任意起名字.为了对应所以修改类名首 ...

  5. cmder 常用配置(包括默认管理员运行和解决中文乱码)

    简介 cmder是一个增强型命令行工具,不仅可以使用windows下的所有命令,更爽的是可以使用linux的命令,shell命令. 下载 官网地址:http://cmder.net/ 下载的时候,会有 ...

  6. MySQL 5.5版本解决中文乱码问题时my.ini内[mysqld]项中不能再写default-character-set=utf8

    来看看如何解决乱码问题: 在mysql中默认字符集是latin1, 想要设置字符集为uft-8,可以在 my.cnf 文件中添加以下设置: [client] default-character-set ...

  7. (原创)Linux下MySQL 5.5/5.6的修改字符集编码为UTF8(彻底解决中文乱码问题)

    « CloudStack+XenServer详细部署方案(10):高级网络功能应用 (总结)CentOS Linux 5.x在GPT分区不能引导的解决方法 » 2013-1 11 (原创)Linux下 ...

  8. [转]解决get方法传递URL参数中文乱码问题

    来自:http://www.javaeye.com/topic/483158 应用一:解决tomcat下中文乱码问题(先来个简单的) 在tomcat下,我们通常这样来解决中文乱码问题: 过滤器代码: ...

  9. 解决get方法传递URL参数中文乱码问题

    [转]解决get方法传递URL参数中文乱码问题 来自:http://www.javaeye.com/topic/483158 应用一:解决tomcat下中文乱码问题(先来个简单的) 在tomcat下, ...

随机推荐

  1. MySQL 开启与关闭远程访问&&授权前需执行GRANT USAGE ON *.* TO 'cai'@'%' IDENTIFIED BY 'caigan2015';才能终端访问

    MySQL 开启与关闭远程访问 (1)通过MySQL用户去限制访问 权限系统目的: MySQL基于安全考虑root账户一般只能本地访问,但是在开发过程中可能需要打开root的远程访问权限,今天介绍的就 ...

  2. Salted Password Hashing

    Here are some examples of poor wacky hash functions I've seen suggested in forums on the internet. m ...

  3. [Flex] Accordion系列 - Header图标的设置

    <?xml version="1.0" encoding="utf-8"?> <!--Flex中如何通过getHeaderAt()函数以及se ...

  4. crmForm.SubmitCRMForm

    其中函数功能及各参数意思. SubmitCRMForm( Mode, Validate, ForceSubmit, closeWindow)        // we could use this f ...

  5. JAVA中String与StringBuffer的区别

    String和StringBuffer的区别,网上资料可以说是数不胜数,但是看到这篇文章,感觉里面做的小例子很有代表性,所以转一下,并自己做了一点总结. 在java中有3个类来负责字符的操作. 1.C ...

  6. InnoSetup打包exe安装应用程序,并添加卸载图标 转

    http://blog.csdn.net/guoquanyou/article/details/7445773 InnoSetup真是一个非常棒的工具.给我的印象就是非常的精干.所以,该工具已经一步步 ...

  7. BC之Run

    Problem Description AFA is a girl who like runing.Today,he download an app about runing .The app can ...

  8. MapReduce从输入文件到Mapper处理之间的过程

    1.MapReduce代码入口 FileInputFormat.setInputPaths(job, new Path(input)); //设置MapReduce输入格式 job.waitForCo ...

  9. (转载)MonoBehaviour的事件和具体功能总结

    分享一点MonoBehaviour的事件和具体功能总结的基础知识,苦于Visual Studio 2013没有对MonoBehaviour的行为做出智能提示,写个函数都要全手打,记性好的将就着手打,脑 ...

  10. hive数据导出和常用操作

    导出到本地文件 insert overwrite local directory '/home/hadoop'select * from test1; 导出到hdfs insert overwrite ...