MySql安裝步驟圖文教程及中文亂碼的解決方案_Mysql

來源:互聯網
上載者:User

MySql Server安裝步驟如下所示:

1安裝MySql Server

2 安裝MySqlServer管理工具

解壓中文語言套件,將檔案複製到安裝目錄下覆蓋

檔案覆蓋後,開啟軟體佈建語言為中文(CN)

3 MySqlServer開發注意事項(C#)

1.聯結字串:"Server=localhost;Database=100;Uid=root;Pwd='root'"

2.引用MySql.Data.dll;using MySql.Data.MySqlClient;

3.使用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");}}

備份:

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("Database Backup失敗!");return false;}}

還原:

/// <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安裝步驟圖文教程及中文亂碼的解決方案,希望對大家有所協助,如果大家有任何疑問請給我留言,小編會及時回複大家的。在此也非常感謝大家對雲棲社區網站的支援!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.