Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLSTATE[HY000] [1105] unknown error: Code: UNAVAILABLE server does not allow insecure connections, client must use SSL/TLS #69

Open
aiastia opened this issue Apr 3, 2022 · 4 comments

Comments

@aiastia
Copy link

aiastia commented Apr 3, 2022

php think migrate:status

Status Migration ID Started Finished Migration Name

[InvalidArgumentException]
There was a problem connecting to the database: SQLSTATE[HY000] [1105] unknown error: Code: UNAVAILABLE
server does not allow insecure connections, client must use SSL/TLS

@aiastia
Copy link
Author

aiastia commented Apr 3, 2022

.env
MYSQL_ATTR_SSL_CA=/etc/ssl/certs/ca-certificates.crt

@aiastia
Copy link
Author

aiastia commented Apr 3, 2022

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

        // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
        'deploy'          => 0,
        // 数据库读写是否分离 主从式有效
        'rw_separate'     => false,
        // 读写分离后 主服务器数量
        'master_num'      => 1,
        // 指定从服务器序号
        'slave_no'        => '',
        // 是否严格检查字段是否存在
        'fields_strict'   => true,
        // 是否需要断线重连
        'break_reconnect' => false,
        // 监听SQL
        'trigger_sql'     => env('app_debug', true),
        // 开启字段缓存
        'fields_cache'    => false,
    ],

@aiastia
Copy link
Author

aiastia commented Apr 3, 2022

网站访问正常数据库正常 但是执行think-migration 提示client must use SSL/TLS

@aiastia
Copy link
Author

aiastia commented Apr 3, 2022

    if (0 == $config['deploy']) {
        $dbConfig = [
            'adapter'      => $config['type'],
            'host'         => $config['hostname'],
            'name'         => $config['database'],
            'user'         => $config['username'],
            'pass'         => $config['password'],
            'port'         => $config['hostport'],

'params' => $config['params'],(自己添加了此处

            'charset'      => $config['charset'],
            'table_prefix' => $config['prefix'],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant