zoukankan      html  css  js  c++  java
  • SQLSTATE[HY000] [2003] Cant connect to MySQL server

    今天要连远程数据库,结果PHP报错

    Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2003] Can't connect to MySQL server on '192.168.1.252' (13)' in /web/miophp/Etc/geter/Action/IndexAction.php:7 Stack trace: #0 /web/miophp/Etc/geter/Action/IndexAction.php(7): PDO->__construct('mysql:dbname=ba...', 'mio', 'miomio', Array) #1 /web/miophp/Etc/geter/Action/Action.php(11): IndexAction->index() #2 [internal function]: Action->ActionInit('index') #3 /web/miophp/Core/core.php(36): call_user_func(Array, 'index') #4 /web/miophp/Mio.php(30): include('/web/miophp/Cor...') #5 /web/admin/mio/index.php(20): require('/web/miophp/Mio...') #6 {main} thrown in /web/miophp/Etc/geter/Action/IndexAction.php on line 7

     

    我以为是程序有问题 查了半天结果是selinux

     

    [root@mio-253 ~]# getsebool -a | grep httpd

    allow_httpd_anon_write --> off

    allow_httpd_mod_auth_ntlm_winbind --> off

    allow_httpd_mod_auth_pam --> off

    allow_httpd_sys_script_anon_write --> off

    httpd_builtin_scripting --> on

    httpd_can_check_spam --> off

    httpd_can_network_connect --> off

    httpd_can_network_connect_cobbler --> off

    httpd_can_network_connect_db --> off

    httpd_can_network_memcache --> off

    httpd_can_network_relay --> off

    httpd_can_sendmail --> off

    httpd_dbus_avahi --> on

    httpd_enable_cgi --> on

    httpd_enable_ftp_server --> off

    httpd_enable_homedirs --> off

    httpd_execmem --> off

    httpd_manage_ipa --> off

    httpd_read_user_content --> off

    httpd_run_stickshift --> off

    httpd_setrlimit --> off

    httpd_ssi_exec --> off

    httpd_tmp_exec --> off

    httpd_tty_comm --> on

    httpd_unified --> on

    httpd_use_cifs --> off

    httpd_use_gpg --> off

    httpd_use_nfs --> off

    httpd_use_openstack --> off

    httpd_verify_dns --> off

    [root@mio-253 ~]# setsebool -P httpd_can_network_connect_db=1

  • 相关阅读:
    2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 C: Coconut
    2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 A: Banana
    第2周项目1c++语言中函数参数传递的三种方式
    第2周项目2程序的多文件组织
    【BZOJ 3224】普通平衡树
    【POJ 1741】Tree
    浅谈树分治
    【luogu 2709 / BZOJ 3781】小B的询问
    【luogu 1972 / BZOJ 1878】HH的项链
    【BZOJ 3339 / BZOJ 3585 / luogu 4137】Rmq Problem / mex
  • 原文地址:https://www.cnblogs.com/phpliu/p/3447059.html
Copyright © 2011-2022 走看看