Trying to get a remote database server running mysqli locally

I created myself a new database via Godaddy and I am tyring to connect my PHP to it via mysqli. He cannot connect to the database. Since the database has just been created, it may not have been activated in their backend yet.

My next step was to try and connect to a different database from the same host, one database I know works; I am currently using it for a Wordpress website, so I know it works. While copying the database information (host, username, password, database name) I still get the same error.

Mysqli works for me when I run it locally on a local database. Here is the error I get (same message for remote databases). I removed the actual host path, but I'm pretty sure I copied / pasted this from my wp-config.php, which is currently running live:

Here is the error I am getting:

Warning: mysqli::mysqli() [<a href='mysqli.mysqli'>mysqli.mysqli</a>]: 
[2002] A connection attempt failed because the connected party did 
not properly respond after a period of time, or established connecti 
(trying to connect via tcp://database.db.host.hostedresource.com:3306)

      

If used, this is how I connect via PHP:

$mysqli = new mysqli('database.db.host.hostedresource.com', 
'database_user', 'password', 'database_name');
if (mysqli_connect_errno())
{
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

      

Any ideas? I know it is not a fact that it is still set to the end of Godaddy because now I am trying to connect to a database that has been running for months and is currently in use.

EDIT:

I'm slowly starting to understand, maybe it's a matter of getting the correct permission (at which end? I don't know) so that my WAMP can connect to the remote database (godaddy). Are there permissions for this?

0


source to share


1 answer


In the godaddy.com hosting interface for your site, click MySQL in Databases . It should open the Database Management dialog box with your new database. The "Status" column should indicate "setup". If it is not, your database is not configured yet or is not configured correctly. If so, please contact technical support. Otherwise, click the Actions button to the right of your database name and select Details... Make sure the database name and hostname are what you are using in your code (probably the same as what WP uses, but check the obvious first). Also try the PhpMyAdmin link and see if you can access the database directly. I would recommend just setting up a different database unless you are trying to do something with WP data.



Edit: Looks like you need to set up a database at godaddy.com with "direct database access" enabled: http://support.godaddy.com/help/article/4978/connecting-remotely-to-shared-hosting-databases ... You may need a different hosting account to do this.

+2


source







All Articles