database.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. use think\facade\Env;
  3. return [
  4. // 默认使用的数据库连接配置
  5. 'default' => Env::get('database.driver', 'mysql'),
  6. // 自定义时间查询规则
  7. 'time_query_rule' => [],
  8. // 自动写入时间戳字段
  9. // true为自动识别类型 false关闭
  10. // 字符串则明确指定时间字段类型 支持 int timestamp datetime date
  11. 'auto_timestamp' => true,
  12. // 时间字段取出后的默认时间格式
  13. 'datetime_format' => 'Y-m-d H:i:s',
  14. // 数据库连接配置信息
  15. 'connections' => [
  16. 'mysql' => [
  17. // 数据库类型
  18. 'type' => Env::get('database.type', 'mysql'),
  19. 'hostname' => '47.112.222.163',
  20. 'database' => 'nn2023021801_1',
  21. 'username' => 'nn2023021801_1',
  22. 'password' => 'tYeBpYBZh4BibxeJ',
  23. 'hostport' => '3306',
  24. // 正式
  25. // 'hostname' => '127.0.0.1',
  26. // 'database' => 'db_db',
  27. // 'username' => 'db_db',
  28. // 'password' => '',
  29. // 'hostport' => '33067',
  30. // 数据库连接参数
  31. 'params' => [],
  32. // 数据库编码默认采用utf8
  33. 'charset' => 'utf8',
  34. // 数据库表前缀
  35. 'prefix' => 'db_',
  36. // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
  37. 'deploy' => 0,
  38. // 数据库读写是否分离 主从式有效
  39. 'rw_separate' => false,
  40. // 读写分离后 主服务器数量
  41. 'master_num' => 1,
  42. // 指定从服务器序号
  43. 'slave_no' => '',
  44. // 是否严格检查字段是否存在
  45. 'fields_strict' => true,
  46. // 是否需要断线重连
  47. 'break_reconnect' => true,
  48. // 监听SQL
  49. 'trigger_sql' => true,
  50. // 开启字段缓存
  51. 'fields_cache' => false,
  52. // 字段缓存路径
  53. 'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR,
  54. ],
  55. // 更多的数据库配置信息
  56. ],
  57. ];