#!/bin/bash # # # host="172.25.254.34" #數據庫所在地址。默認是localhost port=3306 #數據庫所在端口。默認是3306 user="root" #數據庫的用戶名 password="1qazvfr4" #密碼 db="utel" #要同步的數據庫名。要同步多個db可以將本腳本複製多份 api_key="944596276893ec296069f13ff3feab741965521259" #api_key api_token="85f40f87fa27bfe1f173bca5a36e75671783129518" #api_token cat_name="03資料庫" #可選。如果想把生成的文檔都放在項目的子目錄下,則這裡填寫子目錄名。 url="http://nas.zltest.com.tw:7999/server/?s=/api/open/updateDbItem" #可選。同步到的url。如果是使用www.showdoc.com.cn ,則不需要再改此項。如果是部署私有版版showdoc,請改此項為http://xx.com/server/index.php?s=/api/open/updateDbItem 。其中xx.com為你的部署域名 # # # # # # export MYSQL_PWD=${password} COMMAND="set names utf8;select TABLE_NAME ,TABLE_COMMENT from tables where TABLE_SCHEMA ='${db}' " declare table_info=`mysql -h${host} -P${port} -u${user} --show-warnings=false -D information_schema -e "${COMMAND}" ` #echo $table_info COMMAND="set names utf8;select TABLE_NAME ,COLUMN_NAME, COLUMN_DEFAULT ,IS_NULLABLE ,COLUMN_TYPE ,COLUMN_COMMENT from COLUMNS where TABLE_SCHEMA ='${db}' " declare table_detail=`mysql -h${host} -P${port} -u${user} --show-warnings=false -D information_schema -e "${COMMAND}" ` #echo $table_detail table_info2=${table_info//&/_this_and_change_} table_detail2=${table_detail//&/_this_and_change_} curl -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' "${url}" --data-binary @- <