1、mysqlfrm安裝
—————————–
由于mysqlfrm是mysql-utilities工具一部分,那么我們安裝mysql-utilities即可,下載好對(duì)應(yīng)的源碼包,進(jìn)行編譯安裝。
shell>?tar?-xvzf?mysql-utilities-1.6.4.tar.gz? shell>?cd?mysql-utilities-1.6.4 shell>?python?./setup.py?build shell>?python?./setup.py?install
安裝完成后,在相應(yīng)的python執(zhí)行目錄下,就能mysqlfrm等執(zhí)行文件了。
2、mysqlfrm相關(guān)參數(shù)介紹
——————————-
--basedir?:如?--basedir=/usr/local/percona-5.6.21 --server?:?如?--server=user:password@192.168.1.100:3306 --diagnostic?:?開(kāi)啟按字節(jié)模式來(lái)恢復(fù)frm結(jié)構(gòu) --user?:啟動(dòng)MySQL用戶,通過(guò)為mysql
3、mysqlfrm使用
————————-
使用–basedir模式恢復(fù):
[?16:35:29-root@br3cy1sw:~?]#?mysqlfrm?--basedir=/usr/local/percona-5.6.21/?/root/t1.frm?--port=3434?--user=mysql?--diagnostic #?WARNING?The?--port?option?is?not?used?in?the?--diagnostic?mode. #?WARNING:?The?--user?option?is?only?used?for?the?default?mode. #?WARNING:?Cannot?generate?character?set?or?collation?names?without?the?--server?option. #?CAUTION:?The?diagnostic?mode?is?a?best-effort?parse?of?the?.frm?file.?As?such,?it?may?not?identify?all?of?the?components?of?the?table?correctly.?This?is?especially?true?for?damaged?files.?It?will?also?not?read?the?default?values?for?the?columns?and?the?resulting?statement?may?not?be?syntactically?correct. #?Reading?.frm?file?for?/root/t1.frm: #?The?.frm?file?is?a?TABLE. #?CREATE?TABLE?Statement: CREATE?TABLE?`root`.`t1`?( `a`?int(11)?NOT?NULL, `b`?int(11)?DEFAULT?NULL, `c`?int(11)?DEFAULT?NULL, `d`?varchar(600)?DEFAULT?NULL, PRIMARY?KEY?`PRIMARY`?(`a`), KEY?`idx_t1_bc`?(`b`,`c`) )?ENGINE=InnoDB; ????#...done.
使用–server方式恢復(fù):
[?16:35:10-root@br3cy1sw:~?]#mysqlfrm?--server=user:password@192.168.1.100:3306?/root/t1.frm?--port=3434?--user=mysql?--diagnostic WARNING:?Using?a?password?on?the?command?line?interface?can?be?insecure. #?WARNING?The?--port?option?is?not?used?in?the?--diagnostic?mode. #?WARNING:?The?--user?option?is?only?used?for?the?default?mode. #?Source?on?192.168.1.100:?...?connected. #?CAUTION:?The?diagnostic?mode?is?a?best-effort?parse?of?the?.frm?file.?As?such,?it?may?not?identify?all?of?the?components?of?the?table?correctly.?This?is?especially?true?for?damaged?files.?It?will?also?not?read?the?default?values?for?the?columns?and?the?resulting?statement?may?not?be?syntactically?correct. #?Reading?.frm?file?for?/root/t1.frm: #?The?.frm?file?is?a?TABLE. #?CREATE?TABLE?Statement: CREATE?TABLE?`root`.`t1`?(?`a`?int(11)?NOT?NULL,?`b`?int(11)?DEFAULT?NULL,?`c`?int(11)?DEFAULT?NULL, `d`?varchar(200)?COLLATE?`utf8_general_ci`?DEFAULT?NULL, PRIMARY?KEY?`PRIMARY`?(`a`), KEY?`idx_t1_bc`?(`b`,`c`) )?ENGINE=InnoDB?DEFAULT?CHARSET=utf8; ????#...done.
注意到?jīng)]有,使用–basedir恢復(fù)出來(lái)的varchar竟然是–server模式的3倍;這應(yīng)該是mysqlfrm在使用basedir模式時(shí),無(wú)法進(jìn)行字符編碼校驗(yàn)所致引起的。
再次看了下–server的文件:(重點(diǎn)看標(biāo)紅加粗的文字),建議:能用–server模式時(shí),盡量使用–server同時(shí)保證提供mysqld環(huán)境與原生產(chǎn)環(huán)境的一致。
--server=server Connection?information?for?a?server.?Use?this?option?or?--basedir?for?the?default?mode. ? If?provided?with?the?diagnostic?mode,?the?storage?engine?and?character?set?information?are?validated?against?this?server.
? 版權(quán)聲明
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載。
THE END