Ich erstelle eine Website mit Codeigniter (Version: 3.05), PHP (Version: 5.6.24), MySQL (Version : 10.1.16 mariaDB). Auf dem lokalen Server: Betriebssystem = OSX, PHP-Version = 5.6.24, MySQL-Version = 10.1.16 mariaDB. Bei Hosting Server: Betriebssystem = FreeBSD (unix), phpversion = 5.6.30, mysql version =: 5.5.38-log. Die Site funktioniert auf dem lokalen Server einwandfrei. Aber es gibt einen Fehler auf dem Live-Server, wie unten gezeigt.Codeigniter Fehlermeldung auf Live-Server: mysqli :: real_connect(): (HY000/2002): Verbindung verweigert
A PHP Error was encountered
Severity: Warning
Message: mysqli::real_connect(): (HY000/2002): Connection refused
Filename: mysqli/mysqli_driver.php
Line Number: 202
Backtrace:
File: /home/sv-001/www/user/myweb/application/third_party/MX/Loader.php
Line: 109
Function: DB
File: /home/sv-001/www/user/myweb/application/third_party/MX/Loader.php
Line: 65
Function: initialize
File: /home/sv-001/www/user/myweb/application/modules/home/controllers/Home.php
Line: 8
Function: __construct
File: /home/sv-001/www/user/myweb/index.php
Line: 294
Function: require_once
Ich habe meine Datenbankdatei (database.php) mehrmals wurde die Überprüfung, aber ich habe keinen Fehler es in Bezug auf Hostname, Benutzername, Passwort, Datenbanknamen finden.
database.php Datei
$db['default'] = array(
'dsn' => '',
'hostname' => 'testurl.com',
'username' => 'username',
'password' => 'password',
'database' => 'dbname',
'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
);
config.php ist wie folgt:
if($_SERVER['HTTP_HOST'] == "localhost" OR $_SERVER['HTTP_HOST'] == "testurl.com")
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/myfolder/myfolder2/';
else if($_SERVER['HTTP_HOST'] == "testurl.com" OR $_SERVER['HTTP_HOST'] == "testurl.com")
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/myfolder2/';
else
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'];
$config['index_page'] = 'index.php';
//$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
$config['url_suffix'] = '';
$config['language'] = 'english';
$config['charset'] = 'UTF-8';
$config['enable_hooks'] = FALSE;
$config['subclass_prefix'] = 'MY_';
$config['composer_autoload'] = FALSE;
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd';
$config['log_threshold'] = 0;
$config['log_path'] = '';
$config['log_file_extension'] = '';
$config['log_file_permissions'] = 0644;
$config['log_date_format'] = 'Y-m-d H:i:s';
$config['error_views_path'] = '';
$config['cache_path'] = '';
$config['cache_query_string'] = FALSE;
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
//$config['sess_save_path'] = NULL;
$config['sess_save_path'] = APPPATH . 'cache';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;
$config['standardize_newlines'] = FALSE;
$config['global_xss_filtering'] = FALSE;
$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
//$config['csrf_regenerate'] = TRUE;
$config['csrf_regenerate'] = FALSE;
$config['csrf_exclude_uris'] = array();
$config['compress_output'] = FALSE;
$config['time_reference'] = 'local';
$config['rewrite_short_tags'] = FALSE;
$config['proxy_ips'] = '';
zeigen Sie Ihre Datei config/database.php –
Sind Sie sicher, dass Ihr Mariadb-Dienst ausgeführt wird? Funktioniert es am Standardport? –
Erste 2 Treffer auf Google mit "mysqli :: real_connect(): (HY000/2002)": [erste] (http://stackoverflow.com/questions/29928109/getting-error-mysqlireal-connect-hy000-2002- no-so-Datei-oder-Verzeichnis-wh), [zweite] (http://stackoverflow.com/questions/13769504/mysqlimysqli-hy000-2002-cant-connect-to-local-mysql-server-through-sock). Nach dem Aussehen dieser und mehr Ergebnisse: Ihre Konfiguration könnte falsch sein, verwenden Sie "localhost" oder "127.0.0.1" für Ihren "Hostnamen". Überprüfen Sie, ob der DB-Dienst ausgeführt wird. Vielleicht beide. – Nukeface