• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems with database connection

#1
Whenever I try to load the sessions library in my controller I get an error message on my page:

Message: mysqli::real_connect(): (HY000/1045): Access denied for user ''@'(my external ip)' (using password: NO)

I think my database.php file is properly configured. x.x.x.x is the ip of a remote database I can connect to through DBeaver. Either way it seems the connection is completely ignoring my configurations.

I should probably add that I'm using docker-compose with this image, but I don't think it's related.

PHP Code:
$db['default'] = array(
    
'dsn'    => '',
    
'hostname' => 'x.x.x.x',
    
'database_user' => 'username',
    
'database_password' => 'password',
    
'databasename' => '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
); 
Reply

#2
https://www.codeigniter.com/user_guide/d...t=database

In your array you have database_username where it should be just username.

Are you using CI3? (Too lazy to check if CI4 uses different array key names Tongue )
Reply

#3
(09-04-2018, 07:34 AM)Pertti Wrote: https://www.codeigniter.com/user_guide/d...t=database

In your array you have database_username where it should be just username.

Are you using CI3? (Too lazy to check if CI4 uses different array key names Tongue )

Hmm, very odd. I'm using CI 3.1.9 and I don't recall messing with this file, but as a beginner I suppose I must have done something very wrong at some point. Thank you, I've been dealing with this for longer than I'd like to admit.

Edit: Yeah, solved it.
Reply

#4
Hey it's most of the time something glaring obvious right in front of you, but you just can't see it in your own code.

Glad it worked Smile
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.