mysql生成数据字典

时间:2023-03-09 07:14:54
mysql生成数据字典

git clone https://github.com/twindb/undrop-for-innodb.git

make

[root@redis01 undrop-for-innodb]# make
cc -D_FILE_OFFSET_BITS= -Wall -g -O3 -pipe -I./include -c stream_parser.c
cc -D_FILE_OFFSET_BITS= -Wall -g -O3 -pipe -I./include -pthread -lm stream_parser.o -o stream_parser
flex sql_parser.l
sql_parser.l:: warning, the character range [
-Y] is ambiguous in a case-insensitive scanner
sql_parser.l:: warning, the character range [a] is ambiguous in a case-insensitive scanner
bison -o sql_parser.c sql_parser.y
sql_parser.y: conflicts: shift/reduce
cc -D_FILE_OFFSET_BITS= -Wall -g -O3 -pipe -I./include -c sql_parser.c
lex.yy.c:: warning: ‘yyunput’ defined but not used
lex.yy.c:: warning: ‘input’ defined but not used
cc -D_FILE_OFFSET_BITS= -Wall -g -O3 -pipe -I./include -c c_parser.c
./include/ctype-latin1.c:: warning: ‘my_mb_wc_latin1’ defined but not used
./include/ctype-latin1.c:: warning: ‘my_wc_mb_latin1’ defined but not used
cc -D_FILE_OFFSET_BITS= -Wall -g -O3 -pipe -I./include -c tables_dict.c
cc -D_FILE_OFFSET_BITS= -Wall -g -O3 -pipe -I./include -c print_data.c
cc -D_FILE_OFFSET_BITS= -Wall -g -O3 -pipe -I./include -c check_data.c
cc -D_FILE_OFFSET_BITS= -Wall -g -O3 -pipe -I./include sql_parser.o c_parser.o tables_dict.o print_data.o check_data.o -o c_parser -pthread -lm
cc -D_FILE_OFFSET_BITS= -Wall -g -O3 -pipe -I./include -o innochecksum_changer innochecksum.c

创建恢复数据库

create database recovery;

抽取数据字典

create database recovery;
./stream_parser -f /data/mysql//ibdata1
mkdir -p dumps/default
./c_parser -6f pages-ibdata1/FIL_PAGE_INDEX/0000000000000001.page -t dictionary/SYS_TABLES.sql > dumps/default/SYS_TABLES 2> dumps/default/SYS_TABLES.sql
./c_parser -6f pages-ibdata1/FIL_PAGE_INDEX/0000000000000003.page -t dictionary/SYS_INDEXES.sql > dumps/default/SYS_INDEXES 2> dumps/default/SYS_INDEXES.sql
加载数据
mysql -u root -p recovery < dictionary/SYS_TABLES.sql
mysql -u root -p recovery < dictionary/SYS_INDEXES.sql
mysql -u root -p recovery < dumps/default/SYS_TABLES.sql
mysql -u root -p recovery < dumps/default/SYS_INDEXES.sql

  

查看数据信息

mysql> select * from SYS_TABLES where name like '%tb%';
+-------+----+--------+------+--------+---------+--------------+-------+
| NAME | ID | N_COLS | TYPE | MIX_ID | MIX_LEN | CLUSTER_NAME | SPACE |
+-------+----+--------+------+--------+---------+--------------+-------+
| ht/tb | | | | | | | |
+-------+----+--------+------+--------+---------+--------------+-------+
row in set (0.00 sec)
mysql> select * from SYS_INDEXES where table_id=;
+----------+----+---------+----------+------+-------+---------+
| TABLE_ID | ID | NAME | N_FIELDS | TYPE | SPACE | PAGE_NO |
+----------+----+---------+----------+------+-------+---------+
| | | PRIMARY | | | | |
+----------+----+---------+----------+------+-------+---------+
row in set (0.00 sec)