CI 묻고 답하기

제목 mysqli::real_connect(): (HY000/2002): Connection refused
카테고리 CI 2, 3
글쓴이 최삐 작성시각 2017/08/07 19:09:14
댓글 : 3 추천 : 0 스크랩 : 0 조회수 : 59508   RSS

안녕하세요 초보 개발자입니다.

 

현재 서버 이전을 하고 있는데 컴파일 설치를 잘못해서 

mysql 연동이 제대로 안된건지 

자꾸 Connection refused 에러가 납니다.. 

 

붙여넣기를 하니까 에디터 개행이 안되서 양해 부탁드립니다..

Severity: Warning Message: mysqli::real_connect(): (HY000/2002): Connection refused Filename: mysqli/mysqli_driver.php Line Number: 202 Backtrace: File: /data/www/adserver/webdata/application/models/Contents_model.php Line: 7 Function: database File: /data/www/adserver/webdata/application/controllers/Contents.php Line: 6 Function: model File: /data/www/adserver/webdata/index.php Line: 292 Function: require_once 

 

환경은 CentOS 6.9, Apache 2.4, PHP 5.6.17, MariaDB 5.5.57 입니다. 

 

현재 서버에 웹이랑 DB같이 있고 mysql 접속 가능합니다. 

외부에서도 telnet 3306 포트 잘 열려있고, workbench를 통해 mysql 접속 잘 되고 있습니다. 

근데 웹 서버 접속하여 DB 로드 시 저 에러가 나타나고 있습니다.. 

 

처음엔 php.ini 파일은 로드안되어 있어서 이 에러가 났었는데 로드 후에도 똑같이 에러가 나고 있습니다. 

config/database.php에는 문제가 없어 보입니다.. 

 

[application/config/database.php] 

$active_group = 'default'; 

$query_builder = TRUE; 

$db['default'] = array(     'dsn' => 'aaaa.co.kr',     'hostname' => '127.0.0.1',     'username' => 'root',     'password' => '****',     'database' => 'db_name',     'dbdriver' => 'mysqli',     'dbprefix' => '',     'pconnect' => FALSE,     'db_debug' => (ENVIRONMENT !== 'production'),     'cache_on' => FALSE,     'cachedir' => '',     'char_set' => 'utf8',     'dbcollat' => 'utf8_general_ci',     'swap_pre' => '',     'encrypt' => FALSE,     'compress' => FALSE,     'stricton' => FALSE,     'failover' => array(),     'save_queries' => TRUE ); 

 

[php.ini] 

PHP Version => 5.6.17 

System => Linux localhost.localdomain 2.6.32-696.el6.x86_64 #1 SMP Tue Mar 21 19:29:05 UTC 2017 x86_64 Build Date => Aug  7 2017 17:37:23 Configure Command =>  './configure'  '--enable-maintainer-zts' '--prefix=/usr/local/php' '--with-curl' '--with-apxs2=/usr/local/apache/bin/apxs' '--with-mysql' '--with-mysqli' '--with-ldap' '--with-ldap-sasl' '--with-openssl' Server API => Command Line Interface Virtual Directory Support => enabled Configuration File (php.ini) Path => /usr/local/php/lib Loaded Configuration File => /usr/local/php/lib/php.ini Scan this dir for additional .ini files => (none) Additional .ini files parsed => (none) PHP API => 20131106 PHP Extension => 20131226 Zend Extension => 220131226 Zend Extension Build => API220131226,TS PHP Extension Build => API20131226,TS Debug Build => no Thread Safety => enabled Zend Signal Handling => disabled Zend Memory Manager => enabled Zend Multibyte Support => disabled IPv6 Support => enabled DTrace Support => disabled 

Registered PHP Streams => https, ftps, php, file, glob, data, http, ftp, phar Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, sslv2, tls, tlsv1.0, tlsv1.1, tlsv1.2 Registered Stream Filters => convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk 

This program makes use of the Zend Scripting Language Engine: Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies 

... 

mysql 

MySQL Support => enabled Active Persistent Links => 0 Active Links => 0 Client API version => mysqlnd 5.0.11-dev - 20120503 - $Id: $ 

Directive => Local Value => Master Value mysql.allow_local_infile => On => On mysql.allow_persistent => On => On mysql.connect_timeout => 60 => 60 mysql.default_host => no value => no value mysql.default_password => no value => no value mysql.default_port => no value => no value mysql.default_socket => /var/lib/mysql/mysql.sock => /var/lib/mysql/mysql.sock mysql.default_user => no value => no value mysql.max_links => Unlimited => Unlimited mysql.max_persistent => Unlimited => Unlimited mysql.trace_mode => Off => Off 

mysqli 

MysqlI Support => enabled Client API library version => mysqlnd 5.0.11-dev - 20120503 - $Id: $ Active Persistent Links => 0 Inactive Persistent Links => 0 Active Links => 0 

Directive => Local Value => Master Value mysqli.allow_local_infile => On => On mysqli.allow_persistent => On => On mysqli.default_host => no value => no value mysqli.default_port => 3306 => 3306 mysqli.default_pw => no value => no value mysqli.default_socket => /var/lib/mysql/mysql.sock => /var/lib/mysql/mysql.sock mysqli.default_user => no value => no value mysqli.max_links => Unlimited => Unlimited mysqli.max_persistent => Unlimited => Unlimited mysqli.reconnect => Off => Off mysqli.rollback_on_cached_plink => Off => Off 

mysqlnd 

mysqlnd => enabled Version => mysqlnd 5.0.11-dev - 20120503 - $Id: $ Compression => not supported core SSL => supported extended SSL => not supported Command buffer size => 4096 Read buffer size => 32768 Read timeout => 31536000 Collecting statistics => Yes Collecting memory statistics => No Tracing => n/a Loaded plugins => mysqlnd,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password API Extensions => mysqli,mysql ... 

 

 

답변 부탁드립니다. 감사합니다.

 다음글 전역변수 생성하는 방법이 있을까요? (1)
 이전글 ci 2.x대에서는 쿼리문을 생성한후에 실행하지않고 쿼... (3)

댓글

kaido / 2017/08/08 09:15:50 / 추천 0

dsn 부분을 비워보시고 hostname 에서도 포트번호를 제거해 보세요.

최삐 / 2017/08/08 17:12:49 / 추천 0
//kaido 변화가 없습니다.. ㅠ
kaido / 2017/08/09 09:12:38 / 추천 0

hostname 에는 127.0.0.1 이 들어가 있나요?

로컬호스트가 아니라 실제 주소로 넣어보세요.

DB에서 로컬호스트를 허용 안했을 수도 있습니다.

외부 접속은 된다고 하니 외부 주소는 허용되어 있을테구요.

이런 문제는 보통 간단한 부분에서 미스하는 거라서 차근차근 해보시는 수밖에 없습니다.