毅窝疯

centos php-fpm 连接数据库错误2003 (13)

By hybnx 2018-09-29 sql相关 来源:本站 访问:241

本地使用php-fpm+nginx连接远程数据库正常,centos上同样的部署报错,如下:

使用php-fpm,连接数据库mysql报错:

服务器运行错误: 数据库db_master2连接失败,异常码:2003,错误原因:SQLSTATE[HY000] [2003] Can't connect to MySQL server on '172.16.150.37' (13)
{
    "ret": 500,
    "data": [],
    "msg": "服务器运行错误: 数据库db_master2连接失败,异常码:2003,错误原因:SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'XXX.XX.XXX.XX' (13)",
    "debug": {
        "stack": [
            "[#0 - 0ms - PHALAPI_INIT]/var/www/err/api/public/index.php(12)",
            "[#1 - 0.2ms - PHALAPI_RESPONSE]/var/www/err/api/vendor/phalapi/kernal/src/PhalApi.php(46)",
            "[#2 - 2.5ms - PHALAPI_FINISH]/var/www/err/api/vendor/phalapi/kernal/src/PhalApi.php(74)"
        ],
        "sqls": [],
        "version": "2.2.3"
    }
}

解决方法:

终端运行  

setsebool httpd_can_network_connect_db on

问题解决