database.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. // local
  20. // 'hostname' => '47.112.222.163',
  21. 'hostname' => 'localhost',
  22. 'database' => 'NN2023021801',
  23. // 'database' => 'mlh_db_temp',
  24. 'username' => 'nn2023021801',
  25. 'password' => '5HDbLDXyWpBDcw3N',
  26. 'hostport' => '3306',
  27. // // test
  28. // 'hostname' => '114.55.89.63',
  29. // 'database' => 'db_db',
  30. // 'username' => 'db_db',
  31. // 'password' => 'x7BBA6tYxjmbR2YC',
  32. // 'hostport' => '33067',
  33. // // Online
  34. // 'hostname' =>'110.42.2.96',
  35. // 'database' => 'db_db',
  36. // 'username' => 'db_db',
  37. // 'password' => 'bZzTRxrF5NRNAjxp',
  38. // 'hostport' => '33067',
  39. // 数据库连接参数
  40. 'params' => [],
  41. // 数据库编码默认采用utf8
  42. 'charset' => 'utf8',
  43. // 数据库表前缀
  44. 'prefix' => 'db_',
  45. // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
  46. 'deploy' => 0,
  47. // 数据库读写是否分离 主从式有效
  48. 'rw_separate' => false,
  49. // 读写分离后 主服务器数量
  50. 'master_num' => 1,
  51. // 指定从服务器序号
  52. 'slave_no' => '',
  53. // 是否严格检查字段是否存在
  54. 'fields_strict' => true,
  55. // 是否需要断线重连
  56. 'break_reconnect' => true,
  57. // 监听SQL
  58. 'trigger_sql' => true,
  59. // 开启字段缓存
  60. 'fields_cache' => false,
  61. // 字段缓存路径
  62. 'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR,
  63. ],
  64. // 更多的数据库配置信息
  65. ],
  66. ];