mirror of
https://github.com/201206030/novel-plus.git
synced 2025-04-26 17:20:52 +00:00
MySQL 8.0+ 默认使用 caching_sha2_password 认证插件,这种认证方式有两种工作模式: - 如果使用SSL连接,直接通过安全通道传输密码 - 如果不使用SSL连接,客户端需要从服务器获取RSA公钥来加密密码 当设置 useSSL=false 但未明确允许公钥检索时,JDBC驱动出于安全考虑会阻止这种操作(报错:Public Key Retrieval is not allowed)。 生产环境中,应优先考虑: 1. 启用 SSL/TLS 加密连接 2. 如需禁用 SSL,改用 mysql_native_password 认证 3. 仅在受控环境(如开发环境)中使用 allowPublicKeyRetrieval=true
54 lines
1.6 KiB
Java
54 lines
1.6 KiB
Java
mode:
|
||
# 单机模式
|
||
type: Standalone
|
||
# 元数据持久化
|
||
repository:
|
||
# 数据库持久化
|
||
type: JDBC
|
||
|
||
# 数据源配置
|
||
dataSources:
|
||
ds_1:
|
||
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
|
||
driverClassName: com.mysql.cj.jdbc.Driver
|
||
jdbcUrl: jdbc:mysql://localhost:3306/novel_plus?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||
username: root
|
||
password: test123456
|
||
ds_2:
|
||
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
|
||
driverClassName: com.mysql.cj.jdbc.Driver
|
||
url: jdbc:mysql://localhost:3306/information_schema?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||
username: root
|
||
password: test123456
|
||
# 规则配置
|
||
rules:
|
||
- !SINGLE
|
||
tables:
|
||
- "*.*"
|
||
- !SHARDING
|
||
tables: # 数据分片规则配置
|
||
book_content:
|
||
# 分库策略,缺省表示使用默认分库策略
|
||
actualDataNodes: ds_${1}.book_content${0..9}
|
||
# 分表策略
|
||
tableStrategy:
|
||
standard:
|
||
# 分片列名称
|
||
shardingColumn: index_id
|
||
# 分片算法名称
|
||
shardingAlgorithmName: bookContentSharding
|
||
|
||
shardingAlgorithms:
|
||
bookContentSharding:
|
||
# 行表达式分片算法,使用 Groovy 的表达式,提供对 SQL 语句中的 = 和 IN 的分片操作支持
|
||
type: INLINE
|
||
props:
|
||
# 分片算法的行表达式
|
||
algorithm-expression: book_content${index_id % 10}
|
||
|
||
|
||
|
||
props:
|
||
# 是否在日志中打印 SQL
|
||
sql-show: true
|