mysqlfrm を使用して frm テーブル構造を復元する方法

一个新手
リリース: 2017-10-17 10:08:43
オリジナル
3529 人が閲覧しました

1. Mysqlfrm のインストール

--------------------------------

mysqlfrm は mysql の一部であるため-utilities ツールを使用すると、mysql-utilities をインストールし、対応するソース コード パッケージをダウンロードし、コンパイルしてインストールできます。

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
ログイン後にコピー

インストールが完了すると、mysqlfrm とその他の実行可能ファイルが対応する Python 実行ディレクトリに存在するようになります。

2. mysqlfrm 関連パラメータの紹介

--------------------------------

--basedir :如 --basedir=/usr/local/percona-5.6.21
--server : 如 --server=user:password@192.168.1.100:3306
--diagnostic : 开启按字节模式来恢复frm结构
--user :启动MySQL用户,通过为mysql
ログイン後にコピー

3. mysqlfrm を使用します

-------------------------------------

--basedir モードを使用して復元します:

[ 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 モード:

[ 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.
ログイン後にコピー

--basedir を使用して復元された varchar が --server モードの 3 倍であることに気づきましたか? これは、basedir モードを使用するときに mysqlfrm が文字エンコーディングの検証を実行できないことが原因であるはずです。 。

--server ファイルをもう一度見てください: (赤色と太字のテキストに注目してください)、提案: --server モードを使用できる場合は、mysqld 環境が元の環境と一貫していることを確認しながら --server を使用してみてください。本番環境 。

りー

以上がmysqlfrm を使用して frm テーブル構造を復元する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!