MySql安裝步驟圖文教程及中文亂碼的解決方案
MySql Server安裝步驟如下所示:
1安裝MySql Server
2 安裝MySqlServer管理工具
解壓中文語言包,將文件復(fù)制到安裝目錄下覆蓋
文件覆蓋后,打開軟件設(shè)置語言為中文(CN)
3 MySqlServer開發(fā)注意事項(xiàng)(C#)
1.聯(lián)接字符串:"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如果要轉(zhuǎn)為int類型,必須使用Convert來強(qiáng)制轉(zhuǎn)換,否則可能會(huì)出錯(cuò)。
6.修改記錄時(shí),字段數(shù)據(jù)類型如果為Bit類型的時(shí)候,Sql語句中的字段值要使用Ture或False,不能像SqlServer中一樣使用0或1。
7.命令行工具:
public class Cmd { /// <summary> /// 執(zhí)行Cmd命令 /// </summary> /// <param name="workingDirectory">要啟動(dòng)的進(jìn)程的目錄</param> /// <param name="command">要執(zhí)行的命令</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 { //構(gòu)建執(zhí)行的命令 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服務(wù) MessageBox.Show(@"數(shù)據(jù)庫已成功備份到 " + backupPath + " 文件中", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return true; } catch (Exception) { MessageBox.Show("數(shù)據(jù)庫備份失敗!"); return false; } }
還原:
/// <summary> /// 數(shù)據(jù)還原 /// </summary> /// <param name="FilePath">文件路徑</param> /// <returns></returns> public static bool RestoreDB(string FilePath) { try { StringBuilder sbcommand = new StringBuilder(); //在文件路徑后面加上""避免空格出現(xiàn)異常 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("您是否真的想覆蓋以前的數(shù)據(jù)庫嗎?那么以前的數(shù)據(jù)庫數(shù)據(jù)將丟失?。?!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { Cmd.StartCmd(appDirecroty, command); Cmd.StartCmd();//重啟mysql服務(wù) MessageBox.Show("數(shù)據(jù)庫還原成功!"); return true; } return false; } catch (Exception) { MessageBox.Show("數(shù)據(jù)庫還原失?。?); return false; } }
以上所述是小編給大家介紹的MySql安裝步驟圖文教程及中文亂碼的解決方案,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
- MySQL中文亂碼問題解決方案
- 解決Mysql5.7中文亂碼的問題
- 數(shù)據(jù)庫 MySQL中文亂碼解決辦法總結(jié)
- Mysql 下中文亂碼的問題解決方法總結(jié)
- Mac Mysql數(shù)據(jù)庫中文亂碼問題解決
- Mysql徹底解決中文亂碼問題的方案(Illegal mix of collations for operation)
- MYSQL數(shù)據(jù)庫使用UTF-8中文編碼亂碼的解決辦法
- Mysql中文亂碼問題的最佳解決方法
- 解決mysql5中文亂碼問題的方法
- MySQL字符集 GBK、GB2312、UTF8區(qū)別 解決MYSQL中文亂碼問題
- mysql 中文亂碼 解決方法集錦
- 小結(jié)下MySQL中文亂碼,phpmyadmin亂碼,php亂碼 產(chǎn)生原因及其解決方法
- MySQL中文亂碼問題的解決
- 徹底解決MySQL使用中文亂碼的方法
相關(guān)文章
記一次MySQL Slave庫恢復(fù)實(shí)戰(zhàn)記錄
這篇文章主要介紹了記一次MySQL Slave庫恢復(fù)實(shí)戰(zhàn)記錄,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07開啟bin-log日志mysql報(bào)錯(cuò)的解決方法
開啟bin-log日志mysql報(bào)錯(cuò):This function has none of DETERMINISTIC, NO SQL解決辦法,大家參考使用吧2013-12-12MySQL數(shù)據(jù)庫之聯(lián)合查詢?union
這篇文章主要介紹了MySQL數(shù)據(jù)庫之聯(lián)合查詢?union,聯(lián)合查詢就是將多個(gè)查詢結(jié)果的結(jié)果集合并到一起,字段數(shù)不變,多個(gè)查詢結(jié)果的記錄數(shù)合并,下文詳細(xì)介紹需要的小伙伴可以參考一下2022-06-06mysql中用于數(shù)據(jù)遷移存儲(chǔ)過程分享
mysql 數(shù)據(jù)遷移用的一個(gè)存儲(chǔ)過程,需要的朋友可以收藏下。2011-05-05

InnoDB的關(guān)鍵特性-插入緩存,兩次寫,自適應(yīng)hash索引詳解