CodeIgniter Forums
Strange database connection problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Strange database connection problem (/showthread.php?tid=18148)



Strange database connection problem - El Forum - 04-27-2009

[eluser]Mr Lazy[/eluser]
Hi,

I hope someone can help me here, nothing makes any sense. I have just upgraded to 1.7.1 from 1.7.0, but I hoping this is not the source of the strangeness.

I have my database connection details set up in database.php, and I recently deployed the PHP code to a server where there was an old version of the application, which had the same (MySQL) connection details as the new version. I have made no changes to the database user account, just dropped a schema and re-created it.

But now I get the error:

Quote:A Database Error Occurred

Unable to connect to your database server using the provided settings.

Please contact your administrator.

So I copied from database.php and pasted into a terminal my username and password using the command:
Code:
mysql -h localhost -p -u user_name
and I was able to log into MySQL. So if I can copy and paste the connection details (host is localhost), why can't the application connect? The previous version(s) has been running CI and connected without any issues.

Any ideas how I might proceed?

Many Thanks in advance,

Mr L.


Strange database connection problem - El Forum - 04-27-2009

[eluser]slowgary[/eluser]
What about selection of the database? Did you try that command line? Maybe it's a permissions issue? When you're logged in through the terminal you're probably a different user than when your PHP attempts to connect. You say you 'dropped a schema', did you drop and recreate the whole database? You probably need to re-add permissions.


Strange database connection problem - El Forum - 04-27-2009

[eluser]Mr Lazy[/eluser]
Hi,

OK, the weirdness turned out to be my ignorance about my shared database environment. Someone had removed the privileges on the application's database account, which must have prevented it from connecting. A useful lesson for me anyway....

Thanks,

L.