mysqlfrm解析表结构

1.下载并安装相关软件包

地址:mysql-utilities-1.6.5.tar.gz下载地址

[root@cnsz92vl13410 mysql]# ls
mysql-utilities-1.6.5.tar.gz
[root@cnsz92vl13410 mysql]# tar -xvf mysql-utilities-1.6.5.tar.gz 
[root@cnsz92vl13410 ~]# cd /home/mysql/mysql-utilities-1.6.5/
[root@cnsz92vl13410 mysql-utilities-1.6.5]# ls
CHANGES.txt  docs  info.py  LICENSE.txt  mysql  PKG-INFO  README.txt  scripts  setup.py  unit_tests
[root@cnsz92vl13410 mysql-utilities-1.6.5]# python ./setup.py build 
[root@cnsz92vl13410 mysql-utilities-1.6.5]# python ./setup.py install
[root@cnsz92vl13410 mysql-utilities-1.6.5]# mysqlfrm --version
MySQL Utilities mysqlfrm version 1.6.5 
License type: GPLv2

2.使用验证

cnsz92vl13410.cmftdc.cn:test :master > mysql --login-path=root --socket=/dbdata/my5000/var/mysql.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 745
Server version: 5.7.19-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| employees          |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

mysql> create database crmsb;
Query OK, 1 row affected (0.00 sec)

mysql> use crmsb;
Database changed
mysql> create table aaa(id int);
Query OK, 0 rows affected (0.02 sec)

mysql> exit

cnsz92vl13410.cmftdc.cn:test :master >cd /dbdata/my5000/data/
cnsz92vl13410.cmftdc.cn:test :master >ls
auto.cnf  employees       ibdata1  ib_logfile0  ib_logfile2  mysql               sys
crmsb     ib_buffer_pool  ibdata2  ib_logfile1  ibtmp1       performance_schema
cnsz92vl13410.cmftdc.cn:test :master >cd crmsb
cnsz92vl13410.cmftdc.cn:test :master >ls
aaa.frm  aaa.ibd  db.opt
cnsz92vl13410.cmftdc.cn:test :master >mysqlfrm --diagnostic ./aaa.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 ./aaa.frm:
# The .frm file is a TABLE.
# CREATE TABLE Statement:

CREATE TABLE `aaa` (
  `id` int(11) DEFAULT NULL 
) ENGINE=InnoDB;

#...done.

3.该方式同样适用于临时表,可自行测试

你可能感兴趣的:(MySQL)