CodeIgniter Forums
Database connection error when live on server (SOLVED) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Database connection error when live on server (SOLVED) (/thread-68377.html)



Database connection error when live on server (SOLVED) - meSmashsta - 07-02-2017

I configure a VirtualBox VM for my server running UBUNTU (LAMP setup) and now after putting my project on the server it fails to connect to the database.

Error

PHP Code:
mysqli::real_connect(): (HY000/1045): Access denied for user 'usr'@'ip' (using passwordYES



my application/config/database config


PHP Code:
$active_group 'default';
$query_builder TRUE;

$db['default'] = array(
    
'dsn'    => '',
    
'hostname' => '***',
    
'username' => 'miko',
    
'password' => '***',
    
'database' => 'handler_monitoring',
    
'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
); 
Anyway a simple database connection from a pure PHP works, I don't understand why CI wont.
Pure PHP connection that works on the server
PHP Code:
("127.0.0.1""my_user""my_password""my_db" 
Turns out I had the wrong privileges.


RE: Database connection error when live on server - Diederik - 07-02-2017

The error message is pretty clear, you do connect to the MySQL server but it says: Access denied for user 'usr'@'ip' (using password: YES).

So either the username / password combination is false or that user is bound to a specific (different) IP adres.

PS, never post real passwords on a public forum, even if that database is on a local network.


RE: Database connection error when live on server - meSmashsta - 07-02-2017

(07-02-2017, 01:51 PM)Diederik Wrote: The error message is pretty clear, you do connect to the MySQL server but it says: Access denied for user 'usr'@'ip' (using password: YES).

So either the username / password combination is false or that user is bound to a specific (different) IP adres.

PS, never post real passwords on a public forum, even if that database is on a local network.

I got it working thanks, after posting this thread I realized it and fix it but I never got to say it here xD


RE: Database connection error when live on server - rtenny - 07-03-2017

Please add SOLVED to the subject line