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. repo安装

    repo是使用python开发的一个用于多版本管理的工具,可以和git协作,简化git的多版本管理. repo安装: 1.新建~/bin,并将此目录包含在path变量中(如果已存在,且已在path变量 ...

  2. tar.gz和rpm安装文件(转载)

    from:http://bbs.chinaunix.net/thread-2277750-1-1.html Linux软件的二进制分发是指事先已经编译好二进制形式的软件包的发布形式,其优点是安装使用容 ...

  3. 防止sql注入。xss攻击 方法

    //防止sql注入.xss攻击    /**     * 过滤参数     * @param string $str 接受的参数     * @return string     */    publ ...

  4. SVN---脱离SVN控制

    创建一个记事本文件,然后吧这句话复制进去for /r . %%a in (.) do @if exist "%%a\.svn" rd /s /q "%%a\.svn&qu ...

  5. mybatis的动态sql

    案例一: insert语句,然后获取这条语句的id值. <insert id="insertBook" parameterType="modle.Book" ...

  6. [SQL]把同一字段里的多行数据用一行显示

    declare @t table(id int,num int) insert @t , union all , union all , --select * from @t ----查询 decla ...

  7. winmail安装完成后,SMTP/POP3/ADMIN/HTTP/IMAP/LDAP服务不能启动?

    问题原因: 1.特殊端口被占用,可以用命令netstat -ano 查看 2.阿帕奇网络服务 httpd 未开启 解决方案:开启服务后,登录管理工具,点注册,它会自动跳出"httpd通过防火 ...

  8. 增量升级(省流量更新)的Android客户端实现

    转载与 zhouhuiah的专栏 http://blog.csdn.net/zhouhuiah/article/details/16939937 本文在以上两篇博客的基础上再增加了异常处理,并将生成的 ...

  9. 001 The Hello World In Csharp

    C#是面向对象编程语言,语法和JAVA非常相似.接下来让我们看一下C#的Hello world. //001.cs using System; public class Hello { public ...

  10. contentSize、contentInset和contentOffset的区分

    一.  frame.bounds和center的区分 frame:由左边原点和矩形面积组成,其中原点代表其在父视图中的起点位置. bounds:就是原点始终为(0,0)的frame. center:本 ...