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. HTTP Get请求URL最大长度

    各浏览器HTTP Get请求URL最大长度并不相同,几类常用浏览器最大长度及超过最大长度后提交情况如下: IE6.0                :url最大长度2083个字符,超过最大长度后无法提 ...

  2. Beautiful Soup第三方爬虫插件

    什么是BeautifulSoup? Beautiful Soup 是用Python写的一个HTML/XML的解析器,它可以很好的处理不规范标记并生成剖析树(parse tree). 它提供简单又常用的 ...

  3. java多线程之生存者与消费者(Java编程思想)

    1.通过wait() 与 Notify实现 package Produce; import java.util.concurrent.ExecutorService; import java.util ...

  4. Android学习笔记01

    一. 创建Activity的要点: 1.继承Activity类2.需要重写onCreate方法3.需要在AndroidManifest.xml注册4.为Activity添加控件和内容5.setCont ...

  5. python中scipy.misc.logsumexp函数的运用场景

    scipy.misc.logsumexp函数的输入参数有(a, axis=None, b=None, keepdims=False, return_sign=False),具体配置可参见这里,返回的值 ...

  6. PHP 时区设置

    有时候使用date("Y-m-d h:i:s")时发现时间相差8小时,修改“/etc/php5/apache2/php.ini”: date.timezone = "As ...

  7. Java中Split函数的用法技巧

    在java.lang包中也有String.split()方法,与.net的类似,都是返回是一个字符型数组,但使用过程中还有一些小技巧.如执行:"2|33|4".split(&quo ...

  8. mysql 非安装版的一个自动安装脚本及工具(更新版)

    http://blog.csdn.net/iihero/article/details/5596401

  9. ubuntu 命令行软件包管理

    安装软件包 apt-get install vim 卸载 apt-get remove/autoremove vim autoremove 会顺便卸载未使用,未被依赖的软件包 查询或者搜索软件包:: ...

  10. Arch tty终端使用中文,Fbterm控制台配置

    参考: http://www.linuxidc.com/Linux/2011-08/40746p2.htm 安装: # pacman -S fbterm fcitx-fbterm # sudo gpa ...