公告:魔扣目录网为广大站长提供免费收录网站服务,提交前请做好本站友链:【 网站目录:https://www.morko.net 】, 免友链快审服务(50元/站),

点击这里在线咨询客服
新站提交
  • 网站:51998
  • 待审:31
  • 小程序:12
  • 文章:1030137
  • 会员:747

1.前言

作为一名技术人员,少不了接触数据库,那么当遇到一个旧项目数据库表比较多,怎么快速的导出表结构,形成文档方便后续跟进呢?今天我给大家安利一个好用的工具MySQL_markdown。

工具-MySQL数据库表结构快速导出成MarkDown文档

 

2.工具官网代码地址

https://github.com/alicfeng/mysql_markdown

它是一款基于 go 语言编写的一个命令行工具,适用于 linux、mac、windows等平台。

3.直接部署(小白推荐方式)

发布包从官网代码直接下载安装

https://github.com/alicfeng/mysql_markdown/releases
工具-MySQL数据库表结构快速导出成MarkDown文档

下载稳定版本

4.编译部署

有时候我们需要使用工具新特性,可以自行编译此工具,这里也介绍下如何编译最新代码。

4.1部署Go环境

  • 官网下载Go安装包

官网
https://golang.google.cn/dl/下载go安装包,选择合适的平台下载安装即可。

工具-MySQL数据库表结构快速导出成MarkDown文档

Go官网

  • 这里我是macos平台,下载后默认安装在/usr/local/go/目录下。
  • 配置环境变量,追加环境变量。
$ vim ~/.bash_profile

export GOROOT=/usr/local/go/
export GOBIN=$GOROOT/bin

export PATH=$GOBIN:$PATH
  • 生效环境变量
$ source  ~/.bash_profile
  • 验证是否生效
$ which go
/usr/local/go/bin/go

4.2编译工具

编译安装(有编译知识的童鞋可以自行编译)

$ git clone https://github.com/alicfeng/mysql_markdown.git
$ cd mysql_markdown
$ go get "github.com/go-sql-driver/mysql"
$ go build -o /usr/local/bin/mysql_markdown mysql_markdown.go
$ chmod +x /usr/local/bin/mysql_markdown

5.工具语法

$ ./mysql_markdown_mac --help
Usage: mysql_markdown [options...]
--help  This help text
-h      host.     default 127.0.0.1
-u      username. default root
-p      password. default root
-d      database. default mysql
-P      port.     default 3306
-c      charset.  default utf8
-o      output.   default current location
-t      tables.   default all table and support ',' separator for filter

是不是和mysql的语法一样,容易上手。

6.工具实战

下面我以导出mysql表为例,这里注意参数选项和参数值要空一格,切记切记!

$ ./mysql_markdown_mac -h 10.10.10.10 -P 33706 -u root -p kkdd123 -d mysql
1/31 the columns_priv table is making ...
2/31 the db table is making ...
3/31 the engine_cost table is making ...
4/31 the event table is making ...
5/31 the func table is making ...
6/31 the general_log table is making ...
7/31 the gtid_executed table is making ...
8/31 the help_category table is making ...
9/31 the help_keyword table is making ...
10/31 the help_relation table is making ...
11/31 the help_topic table is making ...
12/31 the innodb_index_stats table is making ...
13/31 the innodb_table_stats table is making ...
14/31 the ndb_binlog_index table is making ...
15/31 the plugin table is making ...
16/31 the proc table is making ...
17/31 the procs_priv table is making ...
18/31 the proxies_priv table is making ...
19/31 the server_cost table is making ...
20/31 the servers table is making ...
21/31 the slave_master_info table is making ...
22/31 the slave_relay_log_info table is making ...
23/31 the slave_worker_info table is making ...
24/31 the slow_log table is making ...
25/31 the tables_priv table is making ...
26/31 the time_zone table is making ...
27/31 the time_zone_leap_second table is making ...
28/31 the time_zone_name table is making ...
29/31 the time_zone_transition table is making ...
30/31 the time_zone_transition_type table is making ...
31/31 the user table is making ...
mysql_markdown finished ...

然后你会看到当前目录下会生成一个mysql_20200610_103451.md文件。

工具-MySQL数据库表结构快速导出成MarkDown文档

Typora打开md文档

7.结束

是不是很简单,生成表结构文档,so easy。你学会了吗?

分享到:
标签:文档 MarkDown
用户无头像

网友整理

注册时间:

网站:5 个   小程序:0 个  文章:12 篇

  • 51998

    网站

  • 12

    小程序

  • 1030137

    文章

  • 747

    会员

赶快注册账号,推广您的网站吧!
最新入驻小程序

数独大挑战2018-06-03

数独一种数学游戏,玩家需要根据9

答题星2018-06-03

您可以通过答题星轻松地创建试卷

全阶人生考试2018-06-03

各种考试题,题库,初中,高中,大学四六

运动步数有氧达人2018-06-03

记录运动步数,积累氧气值。还可偷

每日养生app2018-06-03

每日养生,天天健康

体育训练成绩评定2018-06-03

通用课目体育训练成绩评定