通过ssh登录连接内网mysql数据库

2025-06-26 15:07:05 阅读:3 编辑

通过ssh登录

ssh -i C:/Users/Administrator/.ssh/id_rsa -fNL 13307:localhost:3306 -p 22 root@121.37.44.219

测试

$db_flag = "dynamic" . time();
    $param = [
        'driver' => "mysql",
        'host' => "127.0.0.1",
        'port' => 13307,
        'database' => "iot_zhyai_cn",
        'username' => "iot_zhyai_cn",
        'password' => "pXbthHPPM8aT",
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ];
    // 添加一个名为 "dynamic" 的动态连接
    config(['database.connections.' . $db_flag => $param]);

// 获取连接
    $connection = DB::connection($db_flag)->getDoctrineSchemaManager()->listTableNames();
    print_r($connection);

https://www.cnblogs.com/mq0036/p/16325122.html