Home  >  Q&A  >  body text

tp6 database configuration is undefined

'connections'     => [
        'mysql'=> [
            // 数据库类型
            'type'            => env('database.type', 'mysql'),
            // 服务器地址
            'hostname'        => env('database.hostname', '127.0.0.1'),
            // 数据库名
            'database'        => env('database.database', 'test_xyh_com'),
            // 用户名
            'username'        => env('database.username', 'xyh'),
            // 密码
            'password'        => env('database.password', '123456'),
            // 端口
            'hostport'        => env('database.hostport', '3306'),
            // 数据库连接参数
            'params'          => [],
            // 数据库编码默认采用utf8
            'charset'         => env('database.charset', 'utf8'),
            // 数据库表前缀
            'prefix'          => env('database.prefix', ''),

There seems to be no problem with the configuration. I can’t solve it even if I search it on Baidu

在学php了在学php了732 days ago1028

reply all(4)I'll reply

  • 在学php了

    在学php了2022-07-27 09:58:03

    [MYSQL]
    TYPE=mysql
    HOSTNAME=127.0.0.1
    DATABASE=test_xyh_com
    UESRNAME=xyh
    PASSWORD=123456
    HOSTPORT=3306
    CHARSET=utf8
    DEBUG=true
    PREFIX=

    .env is like this. I tried it a few more times and it works. Thank you teacher

    reply
    0
  • autoload

    autoload2022-07-26 16:29:28

    First check whether .env is enabled, this just defines the default options for you

    reply
    0
  • 在学php了

    [MYSQL] TYPE=mysql HOSTNAME=127.0.0.1 DATABASE=test_xyh_com UESRNAME=xyh PASSWORD=123456 HOSTPORT=3306 CHARSET=utf8 DEBUG=true PREFIX= The .env file is set, but it still doesn’t work.

    在学php了 · 2022-07-27 09:54:25
    在学php了

    That's it

    在学php了 · 2022-07-27 09:58:23
  • Cancelreply