消息:mysqli::真实的_connect():(HY000/2002):在docker上运行的phpmyadmin中连接被拒绝- codeigniter

0x6upsns  于 2023-10-15  发布在  PHP
关注(0)|答案(1)|浏览(100)

我试图连接我的codeigniter php到phpmyadmin mysql数据库都运行在docker容器上,但它说Message: mysqli::real_connect(): (HY000/2002): Connection refusedUnable to connect to your database server using the provided settings.
我在localhost运行phpmyadmin:8082和我的codeigniter是在localhost运行:8080
这是我的database.php配置

$db['default'] = array(
    'dsn'      => '',
    'hostname' => '172.20.0.3',  // Use 'localhost' or '127.0.0.1' for a local MySQL database
    'username' => 'root',       
    'password' => 'testpassword',
    'database' => 'sortdb',     
    'dbdriver' => 'mysqli',   
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => TRUE,
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt'  => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);
xmjla07d

xmjla07d1#

通常root只能访问localhost
您可能需要

CREATE USER  root @'172.20.0.3';
GRANT ... TO root @'172.20.0.3' ...;

警告:从远程主机GRANT完全权限到root是不安全的。

相关问题