EXPORT DATABASE CONFIGURATION

描述

EXPORT DATABASE CONFIGURATION 语法用于将 database 中的存储单元和规则配置导出为 YAML 格式。

语法

语法 铁路图

  1. ExportDatabaseConfiguration ::=
  2. 'EXPORT' 'DATABASE' 'CONFIGURATION' ('FROM' databaseName)? ('TO' 'FILE' filePath)?
  3. databaseName ::=
  4. identifier
  5. filePath ::=
  6. string

补充说明

  • 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected

  • 未指定 filePath 时,会将存储单元和规则配置导出至屏幕。

示例

  • 导出指定逻辑库的存储单元和规则配置到指定路径
  1. EXPORT DATABASE CONFIGURATION FROM sharding_db TO FILE "/xxx/config_sharding_db.yaml";
  • 导出指定逻辑库的存储单元和规则配置到屏幕
  1. EXPORT DATABASE CONFIGURATION FROM sharding_db;
  1. mysql> EXPORT DATABASE CONFIGURATION FROM sharding_db;
  2. +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  3. | result |
  4. +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  5. | databaseName: sharding_db
  6. dataSources:
  7. ds_1:
  8. password: 123456
  9. url: jdbc:mysql://127.0.0.1:3306/migration_ds_0
  10. username: root
  11. minPoolSize: 1
  12. connectionTimeoutMilliseconds: 30000
  13. maxLifetimeMilliseconds: 2100000
  14. readOnly: false
  15. idleTimeoutMilliseconds: 60000
  16. maxPoolSize: 50
  17. ds_2:
  18. password: 123456
  19. url: jdbc:mysql://127.0.0.1:3306/db1
  20. username: root
  21. minPoolSize: 1
  22. connectionTimeoutMilliseconds: 30000
  23. maxLifetimeMilliseconds: 2100000
  24. readOnly: false
  25. idleTimeoutMilliseconds: 60000
  26. maxPoolSize: 50
  27. rules:
  28. |
  29. +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. 1 row in set (0.00 sec)
  • 导出当前逻辑库的存储单元和规则配置到指定路径
  1. EXPORT DATABASE CONFIGURATION TO FILE "/xxx/config_sharding_db.yaml";
  • 导出当前逻辑库的存储单元和规则配置到屏幕
  1. EXPORT DATABASE CONFIGURATION;
  1. mysql> EXPORT DATABASE CONFIGURATION;
  2. +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  3. | result |
  4. +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  5. | databaseName: sharding_db
  6. dataSources:
  7. ds_1:
  8. password: 123456
  9. url: jdbc:mysql://127.0.0.1:3306/migration_ds_0
  10. username: root
  11. minPoolSize: 1
  12. connectionTimeoutMilliseconds: 30000
  13. maxLifetimeMilliseconds: 2100000
  14. readOnly: false
  15. idleTimeoutMilliseconds: 60000
  16. maxPoolSize: 50
  17. ds_2:
  18. password: 123456
  19. url: jdbc:mysql://127.0.0.1:3306/db1
  20. username: root
  21. minPoolSize: 1
  22. connectionTimeoutMilliseconds: 30000
  23. maxLifetimeMilliseconds: 2100000
  24. readOnly: false
  25. idleTimeoutMilliseconds: 60000
  26. maxPoolSize: 50
  27. rules:
  28. |
  29. +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. 1 row in set (0.00 sec)

保留字

EXPORTDATABASECONFIGURATIONFROMTOFILE

相关链接