I am using Codeigniter & LAMP stack (without the MySQL) on my localhost to connect to a remote MySQL database on my server. This configuration is for development purposes only.
Problem: It takes up to a minute for the entire page to load! Is there any way to make this connection faster?
Sometimes its so slow i even get the error:
A Database Error Occurred
Unable to select the specified database: x
Filename: /Applications/MAMP/htdocs/x/third_party/MX/Loader.php
Line Number: 96
Unless your app is very hard on the DB, it is very likely that reverse DNS resolution is the cause. Disable it on the remote server by adding skip-name-resolve
to your my.cnf
.
Also, note that even for simple queries, the roundtrip "across the world" may be 200 ms or even more, so it only takes 300 queries to spend a minute on networking, regardless of the complexity or amounts of data.
I got the same error message. The problem was that I didn't set the connection parametres correctly. Douoble-check your Database Server credentials in database.php . Make sure the hostname, username, password and database are correct.