整個恢復過程其實可以總結為下面幾步:
(1):恢復表結構
(2):復制出來創建表的sql語句
(3):恢復表數據(在恢復表數據的時候,首先需要解除當前創建的表與默認生成的.ibd文件間的關系,接着將要恢復數據表的.ibd文件與當前創建的表聯系起來即可)
1.通過官網下載mysql-utilities-1.6.5.tar.gz(https://downloads.mysql.com/archives/utilities/)
#tar xzvf mysql-utilities-1.6.5.tar.gz
#. cd mysql-utilities-1.6.5
#python setup.py install
[root@node01 soft]# cd /data/mysql/mysql3306/
[root@node01 mysql3306]# ll
total 24
drwxr-xr-x 7 mysql mysql 4096 Sep 22 17:05 data
drwxr-xr-x 2 mysql mysql 4096 Sep 22 17:05 logs
-rw-r--r-- 1 mysql mysql 3080 Sep 12 13:09 my3306.cnf
-rw-r--r-- 1 mysql mysql 9890 Jul 20 10:52 my3306.cnf.bak
drwxr-xr-x 2 mysql mysql 6 Sep 22 17:05 tmp
[root@node01 mysql3306]# cd data/
[root@node01 data]# mysqlf
mysqlfailover mysqlfrm
[root@node01 data]# mysqlfrm --diagnostic qq/
db.opt sbtest.frm sbtest.ibd
[root@node01 data]# mysqlfrm --diagnostic qq/sbtest.frm
# 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 qq/sbtest.frm:
# The .frm file is a TABLE.
# CREATE TABLE Statement:
CREATE TABLE `qq`.`sbtest` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`k` int(10) unsigned NOT NULL,
`c` char(360) NOT NULL,
`pad` char(180) NOT NULL,
PRIMARY KEY `PRIMARY` (`id`),
KEY `k` (`k`)
) ENGINE=InnoDB;
#...done.
mysqlfrm 是一個恢復性質的工具,用來讀取.frm文件並從該文件中找到表定義數據生成CREATE語句。在大多數情況下,生成的CREATE語句用於在另一個服務器上創建表或進行診斷等。然而,有些功能是不保存在.frm文件中的,因此這些功能將被忽略的。如:
- 外鍵約束
- 自增長序列
mysqlfrm 有兩種操作模式。默認的模式是再生個實例,使用--basedir選項或指定--server選項來連接到已經安裝的實例。這種過程不會改變原始的.frm文件。該模式也需要指定--port選項來給再生的實例使用,該端口不能與現有的實例沖突。在讀取.frm文件后,再生的實例將被關閉,所有的臨時文件將被刪除的。
另一個模式是診斷模式,需要指定 --diagnostic 選項。byte-by-byte讀取.frm文件 盡可能多的恢復信息。該模式有更多的局限性,不能校驗字符集。
當使用默認模式無法讀取文件或者該服務器上沒有安裝MySQL實例就使用診斷模式。
需要指定.frm文件的路徑,也可以指定一個目錄,該目錄下的所有.frm文件將被讀取。
可以指定數據庫名稱用來產生CREATE語句,格式如下:database_name:table_name.frm,如:oltp:t1.frm。可選的數據庫名稱也可以使用路徑,如 /home/me/oltp:t1.frm,將使用oltp作為數據庫名。如果省略了數據庫名稱和路徑,最后的一個文件夾將作為數據庫名稱的。如 /home/me/data1/t1.frm,data1將作為數據庫名。如果不想最后的文件夾作為數據庫名,只需指定冒號,如 /home/me/data1/:t1.frm,在這種情況下,CREATE語句將忽略數據庫。
選項
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
MySQL Utilities mysqlfrm version 1.5.3
License type: GPLv2
Usage: mysqlfrm --server=[user[:<pass>]@host[:<port>][:<socket>]|<login-path>[:<port>][:<socket>]] [path\tbl1.frm|db:tbl.frm]
mysqlfrm - show CREATE TABLE from .frm files
Options:
--version show program's version number and exit
--license display program's license and exit
--help
--basedir=BASEDIR the base directory for the server,默認模式
--diagnostic read the frm files byte-by-byte to form the CREATE
statement. May require the --server or --basedir
options to decipher character set information
--new-storage-engine=NEW_ENGINE
change ENGINE clause to use this engine.
--frmdir=FRMDIR save the new .frm files in this directory. Used and
valid with --new-storage-engine only.
--port=PORT Port to use for the spawned server.未使用的端口,默認模式
-s, --show-stats show file statistics and general table information.
--server=SERVER connection information for the server in the form:
<user>[:<password>]@<host>[:<port>][:<socket>] or
<login-path>[:<port>][:<socket>] (optional) - if
provided, the storage engine and character set
information will be validated against this server.
--user=USER user account to launch spawned server. Required if
running as root user. Used only in the default mode.
--start-timeout=START_TIMEOUT
Number of seconds to wait for spawned server to start.
Default = 10.
-v, --verbose control how much information is displayed. e.g., -v =
verbose, -vv = more verbose, -vvv = debug
-q, --quiet turn off all messages for quiet execution.
--ssl-ca=SSL_CA The path to a file that contains a list of trusted SSL
CAs.
--ssl-cert=SSL_CERT The name of the SSL certificate file to use for
establishing a secure connection.
--ssl-key=SSL_KEY The name of the SSL key file to use for establishing a
secure connection.
|
注意
1. 某些引擎表在默認模式下不可讀取的。如PARTITION, PERFORMANCE_SCHEMA,必需在診斷模式下可讀。
2. 要在創建語句中改變存儲引擎,可使用--new-storage-engine 選項。如果有指定該選項,同時必須指定--frmdir選項,該工具生成新的.frm文件,前綴為new_,並保存在--frmdir目錄下。
3. 關掉所有信息除了CREATE 語句和警告或錯誤信息,使用--quiet選項。
4. 使用--show-stats 選項統計每個.frm文件信息。
5. 使用--user 選項指定再生的實例以哪個權限運行。
6. 如果再生的實例超過10秒啟動,需調大--start-timeout 選項參數。
實例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
# mysqlfrm --basedir=/usr ttlsa_com:data.frm --port=3333 --user=mysql -vvv
# Checking read access to .frm files
# Creating a temporary datadir = /data/mydata3306/ttlsa_com/5831a350-3c22-4869-a6d7-9c843fe51ac7
# Spawning server with --user=mysql.
# Starting the spawned server on port 3333 ...
# Cloning the MySQL server located at /usr.
# Configuring new instance...
# Locating mysql tools...
# Location of files:
# mysqld: /usr/sbin/mysqld
# mysqladmin: /usr/bin/mysqladmin
# mysql_system_tables.sql: /usr/share/mysql/mysql_system_tables.sql
# mysql_system_tables_data.sql: /usr/share/mysql/mysql_system_tables_data.sql
# mysql_test_data_timezone.sql: /usr/share/mysql/mysql_test_data_timezone.sql
# fill_help_tables.sql: /usr/share/mysql/fill_help_tables.sql
# Setting up empty database and mysql tables...
2015-01-20 19:12:35 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-01-20 19:12:35 18168 [Note] Plugin 'FEDERATED' is disabled.
2015-01-20 19:12:35 18168 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-01-20 19:12:35 18168 [Note] InnoDB: The InnoDB memory heap is disabled
2015-01-20 19:12:35 18168 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-01-20 19:12:35 18168 [Note] InnoDB: Memory barrier is not used
2015-01-20 19:12:35 18168 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-01-20 19:12:35 18168 [Note] InnoDB: Using Linux native AIO
2015-01-20 19:12:35 18168 [Note] InnoDB: Using CPU crc32 instructions
2015-01-20 19:12:35 18168 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-01-20 19:12:35 18168 [Note] InnoDB: Completed initialization of buffer pool
2015-01-20 19:12:35 18168 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2015-01-20 19:12:35 18168 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2015-01-20 19:12:35 18168 [Note] InnoDB: Database physically writes the file full: wait...
2015-01-20 19:12:35 18168 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-01-20 19:12:36 18168 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-01-20 19:12:36 18168 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-01-20 19:12:36 18168 [Warning] InnoDB: New log files created, LSN=45781
2015-01-20 19:12:36 18168 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-01-20 19:12:36 18168 [Note] InnoDB: Doublewrite buffer created
2015-01-20 19:12:36 18168 [Note] InnoDB: 128 rollback segment(s) are active.
2015-01-20 19:12:36 18168 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-01-20 19:12:36 18168 [Note] InnoDB: Foreign key constraint system tables created
2015-01-20 19:12:36 18168 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-01-20 19:12:36 18168 [Note] InnoDB: Tablespace and datafile system tables created.
2015-01-20 19:12:36 18168 [Note] InnoDB: Waiting for purge to start
2015-01-20 19:12:36 18168 [Note] InnoDB: 5.6.22 started; log sequence number 0
2015-01-20 19:12:38 18168 [Note] Binlog end
2015-01-20 19:12:38 18168 [Note] InnoDB: FTS optimize thread exiting.
2015-01-20 19:12:38 18168 [Note] InnoDB: Starting shutdown...
2015-01-20 19:12:39 18168 [Note] InnoDB: Shutdown completed; log sequence number 1625977
# Starting new instance of the server...
# Startup command for new server:
/usr/sbin/mysqld --no-defaults --datadir=/data/mydata3306/ttlsa_com/5831a350-3c22-4869-a6d7-9c843fe51ac7 --tmpdir=/data/mydata3306/ttlsa_com/5831a350-3c22-4869-a6d7-9c843fe51ac7 --pid-file=/data/mydata3306/ttlsa_com/5831a350-3c22-4869-a6d7-9c843fe51ac7/clone.pid --port=3333 --server-id=101 --basedir=/usr --socket=/data/mydata3306/ttlsa_com/5831a350-3c22-4869-a6d7-9c843fe51ac7/mysql.sock --user=mysql
# Testing connection to new instance...
2015-01-20 19:12:40 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-01-20 19:12:40 18193 [Note] Plugin 'FEDERATED' is disabled.
2015-01-20 19:12:40 18193 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-01-20 19:12:40 18193 [Note] InnoDB: The InnoDB memory heap is disabled
2015-01-20 19:12:40 18193 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-01-20 19:12:40 18193 [Note] InnoDB: Memory barrier is not used
2015-01-20 19:12:40 18193 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-01-20 19:12:40 18193 [Note] InnoDB: Using Linux native AIO
2015-01-20 19:12:40 18193 [Note] InnoDB: Using CPU crc32 instructions
2015-01-20 19:12:40 18193 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-01-20 19:12:40 18193 [Note] InnoDB: Completed initialization of buffer pool
2015-01-20 19:12:40 18193 [Note] InnoDB: Highest supported file format is Barracuda.
2015-01-20 19:12:40 18193 [Note] InnoDB: 128 rollback segment(s) are active.
2015-01-20 19:12:40 18193 [Note] InnoDB: Waiting for purge to start
2015-01-20 19:12:40 18193 [Note] InnoDB: 5.6.22 started; log sequence number 1625977
2015-01-20 19:12:40 18193 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 3f618744-a095-11e4-9f53-0050569f3bb8.
2015-01-20 19:12:40 18193 [Note] Server hostname (bind-address): '*'; port: 3333
2015-01-20 19:12:40 18193 [Note] IPv6 is available.
2015-01-20 19:12:40 18193 [Note] - '::' resolves to '::';
2015-01-20 19:12:40 18193 [Note] Server socket created on IP: '::'.
2015-01-20 19:12:40 18193 [Note] Event Scheduler: Loaded 0 events
2015-01-20 19:12:40 18193 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.6.22' socket: '/data/mydata3306/ttlsa_com/5831a350-3c22-4869-a6d7-9c843fe51ac7/mysql.sock' port: 3333 MySQL Community Server (GPL)
# trying again...
# Success!
# Setting the root password...
Warning: Using a password on the command line interface can be insecure.
# Connection Information:
# -uroot -proot --socket=/data/mydata3306/ttlsa_com/5831a350-3c22-4869-a6d7-9c843fe51ac7/mysql.sock
#...done.
# Connecting to spawned server
done.
# Reading .frm files
#
# Reading the data.frm file.
# Changing engine for .frm file /data/mydata3306/ttlsa_com/5831a350-3c22-4869-a6d7-9c843fe51ac7/ttlsa_com_temp/data.frm:
# Skipping to header at : 2
# General Data from .frm file:
{'IO_SIZE': 4096,
'MYSQL_VERSION_ID': 50622,
'avg_row_length': 0,
'charset_low': 0,
'create_options': 8,
'db_create_pack': 2,
'default_charset': 8,
'default_part_eng': 0,
'extra_size': 28,
'frm_file_ver': 5,
'frm_version': 9,
'key_block_size': 0,
'key_info_length': 53,
'key_length': 706,
'legacy_db_type': 'INNODB',
'length': 12288,
'max_rows': 0,
'min_rows': 0,
'rec_length': 39,
'row_type': 0,
'table_charset': 8,
'tmp_key_length': 706}
# Engine string: InnoDB
# Server version in file: 5.6.22
#
# CREATE statement for data.frm:
#
CREATE TABLE `ttlsa_com`.`data` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`value` char(30) NOT NULL DEFAULT '',
`count` int(11) DEFAULT NULL,
PRIMARY KEY (`value`),
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
# Shutting down spawned server
# Removing the temporary datadir
2015-01-20 19:12:40 18193 [Note] /usr/sbin/mysqld: Normal shutdown
2015-01-20 19:12:40 18193 [Note] Giving 0 client threads a chance to die gracefully
2015-01-20 19:12:40 18193 [Note] Event Scheduler: Purging the queue. 0 events
2015-01-20 19:12:40 18193 [Note] Shutting down slave threads
2015-01-20 19:12:40 18193 [Note] Forcefully disconnecting 0 remaining clients
2015-01-20 19:12:40 18193 [Note] Binlog end
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'partition'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'BLACKHOLE'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'ARCHIVE'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_METRICS'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_CMPMEM'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_CMP'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_LOCKS'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'INNODB_TRX'
2015-01-20 19:12:40 18193 [Note] Shutting down plugin 'InnoDB'
2015-01-20 19:12:40 18193 [Note] InnoDB: FTS optimize thread exiting.
2015-01-20 19:12:40 18193 [Note] InnoDB: Starting shutdown...
#...done.
2015-01-20 19:12:42 18193 [Note] InnoDB: Shutdown completed; log sequence number 1625987
2015-01-20 19:12:42 18193 [Note] Shutting down plugin 'CSV'
2015-01-20 19:12:42 18193 [Note] Shutting down plugin 'MEMORY'
2015-01-20 19:12:42 18193 [Note] Shutting down plugin 'MRG_MYISAM'
2015-01-20 19:12:42 18193 [Note] Shutting down plugin 'MyISAM'
2015-01-20 19:12:42 18193 [Note] Shutting down plugin 'sha256_password'
2015-01-20 19:12:42 18193 [Note] Shutting down plugin 'mysql_old_password'
2015-01-20 19:12:42 18193 [Note] Shutting down plugin 'mysql_native_password'
2015-01-20 19:12:42 18193 [Note] Shutting down plugin 'binlog'
2015-01-20 19:12:42 18193 [Note] /usr/sbin/mysqld: Shutdown complete
|
看看執行過程反過頭去看看上面所說是否正確。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# mysqlfrm --basedir=/usr --port=3333 --user=mysql /data/mydata3306/ttlsa_com/data.frm /data/mydata3306/mysql/bbs_ttlsa_com:user.frm
# Spawning server with --user=mysql.
# Starting the spawned server on port 3333 ... done.
# Reading .frm files
#
# Reading the user.frm file.
#
# CREATE statement for /data/mydata3306/mysql/user.frm:
#
CREATE TABLE `bbs_ttlsa_com`.`user` (
`Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
`User` char(16) COLLATE utf8_bin NOT NULL DEFAULT '',
`Password` char(41) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
`Select_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Insert_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Update_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Delete_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Drop_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Reload_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Shutdown_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Process_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`File_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Grant_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`References_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Index_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Alter_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Show_db_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Super_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_tmp_table_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Lock_tables_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Execute_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Repl_slave_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Repl_client_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Show_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Alter_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_user_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Event_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Trigger_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_tablespace_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`ssl_type` enum('','ANY','X509','SPECIFIED') CHARACTER SET utf8 NOT NULL DEFAULT '',
`ssl_cipher` blob NOT NULL,
`x509_issuer` blob NOT NULL,
`x509_subject` blob NOT NULL,
`max_questions` int(11) unsigned NOT NULL DEFAULT '0',
`max_updates` int(11) unsigned NOT NULL DEFAULT '0',
`max_connections` int(11) unsigned NOT NULL DEFAULT '0',
`max_user_connections` int(11) unsigned NOT NULL DEFAULT '0',
`plugin` char(64) COLLATE utf8_bin DEFAULT '',
`authentication_string` text COLLATE utf8_bin,
`password_expired` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
PRIMARY KEY (`Host`,`User`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Users and global privileges'
#
# Reading the data.frm file.
#
# CREATE statement for /data/mydata3306/ttlsa_com/data.frm:
#
CREATE TABLE `ttlsa_com`.`data` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`value` char(30) NOT NULL DEFAULT '',
`count` int(11) DEFAULT NULL,
PRIMARY KEY (`value`),
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
#...done.
|
/data/mydata3306/ttlsa_com/data.frm 數據庫名為ttlsa_com;
/data/mydata3306/mysql/bbs_ttlsa_com:user.frm 數據庫名為bbs_ttlsa_com。
以診斷模式讀取目錄中的所有的FRM文件:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# mysqlfrm --diagnostic /data/mydata3306/ttlsa_com
# 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 /data/mydata3306/ttlsa_com/bbs_categories.frm:
# The .frm file is a TABLE.
# CREATE TABLE Statement:
# Reading .frm file for /data/mydata3306/ttlsa_com/data.frm:
# The .frm file is a TABLE.
# CREATE TABLE Statement:
CREATE TABLE `ttlsa_com`.`data` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`value` char(30) NOT NULL,
`count` int(11) DEFAULT NULL,
PRIMARY KEY `PRIMARY` (`value`),
KEY `id` (`id`)
) ENGINE=InnoDB;
#...done.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
# mysqlfrm --diagnostic /data/mydata3306/ttlsa_com/data.frm -vvv
# 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 /data/mydata3306/ttlsa_com/data.frm:
# The .frm file is a TABLE.
# Skipping to header at : 2
# General Data from .frm file:
{'IO_SIZE': 4096,
'MYSQL_VERSION_ID': 50622,
'avg_row_length': 0,
'charset_low': 0,
'create_options': 8,
'db_create_pack': 2,
'default_charset': 8,
'default_part_eng': 0,
'extra_size': 28,
'frm_file_ver': 5,
'frm_version': 9,
'key_block_size': 0,
'key_info_length': 53,
'key_length': 706,
'legacy_db_type': 'INNODB',
'length': 12288,
'max_rows': 0,
'min_rows': 0,
'rec_length': 39,
'row_type': 0,
'table_charset': 8,
'tmp_key_length': 706}
# Skipping to key data at : 1000
# Reading key part 0.
# Reading key part 0.
# Index (key) Data from .frm file:
{'key_names': ['PRIMARY', 'id'],
'keys': [{'algorithm': 0,
'block_size': 0,
'comment': '',
'flags': 2,
'key_length': 30,
'key_parts': [{'field_num': 2,
'key_part_flag': 0,
'key_type': 0,
'length': 30,
'offset': 5}],
'num_parts': 1},
{'algorithm': 0,
'block_size': 0,
'comment': '',
'flags': 1,
'key_length': 4,
'key_parts': [{'field_num': 1,
'key_part_flag': 0,
'key_type': 6912,
'length': 4,
'offset': 1}],
'num_parts': 1}],
'num_key_parts': (2,),
'num_keys': 2}
# Skipping to default data at : 12c3
# Skipping to keys at : 12eb
# Engine string: InnoDB
# Partition string:
# Skipping to column data at : 2102
{'com_length': 0,
'int_length': 0,
'interval_count': 39,
'interval_parts': 17,
'n_length': 0,
'null_fields': 1,
'num_cols': 3,
'pos': 72,
'unknown': 52}
# Fields per screen = 3
# Reading column metadata #0
# Reading column metadata #1
# Reading column metadata #2
# Column comment: 0
# Column comment: 0
# Column comment: 0
# Column Data from .frm file:
[{'bytes_in_col': 11,
'charset': 8,
'charset_low': 0,
'comment': '',
'comment_length': 0,
'default': None,
'enums': [],
'field_length': 11,
'field_type': 3,
'field_type_name': 'int',
'flags': 27,
'flags_extra': 0,
'interval_nr': 0,
'name': 'id',
'recpos': 2,
'unireg': 0,
'unireg_type': 15},
{'bytes_in_col': 30,
'charset': 8,
'charset_low': 0,
'comment': '',
'comment_length': 0,
'default': None,
'enums': [],
'field_length': 30,
'field_type': 254,
'field_type_name': 'char',
'flags': 0,
'flags_extra': 0,
'interval_nr': 0,
'name': 'value',
'recpos': 6,
'unireg': 0,
'unireg_type': 0},
{'bytes_in_col': 11,
'charset': 8,
'charset_low': 0,
'comment': '',
'comment_length': 0,
'default': None,
'enums': [],
'field_length': 11,
'field_type': 3,
'field_type_name': 'int',
'flags': 27,
'flags_extra': 128,
'interval_nr': 0,
'name': 'count',
'recpos': 36,
'unireg': 0,
'unireg_type': 0}]
# Number of columns: 3
[{'bytes_in_col': 30,
'charset': 8,
'charset_low': 0,
'comment': '',
'comment_length': 0,
'default': None,
'enums': [],
'field_length': 30,
'field_type': 254,
'field_type_name': 'char',
'flags': 0,
'flags_extra': 0,
'interval_nr': 0,
'name': 'value',
'recpos': 6,
'unireg': 0,
'unireg_type': 0},
{'bytes_in_col': 11,
'charset': 8,
'charset_low': 0,
'comment': '',
'comment_length': 0,
'default': None,
'enums': [],
'field_length': 11,
'field_type': 3,
'field_type_name': 'int',
'flags': 27,
'flags_extra': 128,
'interval_nr': 0,
'name': 'count',
'recpos': 36,
'unireg': 0,
'unireg_type': 0}]
# Skipping to table comments at : 202e
# Comment:
# CREATE TABLE Statement:
CREATE TABLE `ttlsa_com`.`data` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`value` char(30) NOT NULL,
`count` int(11) DEFAULT NULL,
PRIMARY KEY `PRIMARY` (`value`),
KEY `id` (`id`)
) ENGINE=InnoDB;
#...done.
|
權限
權限取決於如何使用mysqlfrm。統一用root賬號就好了。
如果要連接服務器,需要對mysql數據庫讀權限。
具體詳細可以參考:http://www.ttlsa.com/mysql/mysql-utilities-mysqlfrm/