I am running a dev LAMP with Codeigniter. However, when I try to load the page, the database can not connect(the database is actually on another server) and I get this error:
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 346
My database.php is this:
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'myhost.com';
$db['default']['username'] = 'myusername';
$db['default']['password'] = 'mypassword';
$db['default']['database'] = 'mytable';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
If I change the 'pconnect' and/or 'db_debug' to false, I get the same error or it just doesn't work. I know the database is up and running correctly because others are able to connect and use it.
However, if I put the IP address of the host into the database.php file, it works. I tried flushing the DNS and even changed to Google's DNS servers to no avail.
The result of a simple mysql_connect is:
A PHP Error was encountered
Severity: Warning
Message: mysql_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known
Filename: config/database.php
Line Number: 67
A PHP Error was encountered
Severity: Warning
Message: mysql_connect(): [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known (trying to connect via tcp://myhost.com:3306)
Filename: config/database.php
Line Number: 67
A PHP Error was encountered
Severity: Warning
Message: mysql_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known
Filename: config/database.php
Line Number: 67
Could not connect: php_network_getaddresses: getaddrinfo failed: Name or service not known