Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have scoured Google trying to discover how to do this, but essentially I want to connect to a colleague's MySQL database for working together on a Wordpress installation.

I am having no luck and keep getting an error about the connection not being possible:

Unable to connect to any of the specified MySQL hosts.

MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
   at MySql.Data.MySqlClient.NativeDriver.Open()
   at MySql.Data.MySqlClient.Driver.Open()
   at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
   at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
   at MySql.Data.MySqlClient.MySqlPool.GetConnection()
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at Microsoft.WebMatrix.DatabaseManager.MySqlDatabase.MySqlDatabaseProvider.TestConnection(String connectionString)
   at Microsoft.WebMatrix.DatabaseManager.IisDbManagerModuleService.TestConnection(DatabaseConnection databaseConnection, String configPathState)
   at Microsoft.WebMatrix.DatabaseManager.Client.ClientConnection.Test(ManagementConfigurationPath configPath)
   at Microsoft.WebMatrix.DatabaseManager.Client.DatabaseHierarchyInfo.EnsureLoaded()

The connection details are copied from my colleague's connection string, with the exception of the server being modified to match the IP address of his machine.

WebMatrix MySQL Connection

I'm not sure if there is a firewall port I have to open or a configuration file I have to modify, but I'm not having much luck so far.

(There is a strong chance that, by default, web matrix / iis express doesn't set the mysql database it creates to accept remote connections. If anyone knows how to change this, that would be grand!)

Anyone have any ideas?

EDIT : Port Opened

I opened the port 3306 on Windows Firewall on my colleague's machine.

Now I have the following error:

Host 'DESKTOP019-PC' is not allowed to connect to this MySQL server

MySql.Data.MySqlClient.MySqlException (0x80004005): Host 'DESKTOP019-PC' is not allowed to connect to this MySQL server
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.Open()
   at MySql.Data.MySqlClient.Driver.Open()
   at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
   at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
   at MySql.Data.MySqlClient.MySqlPool.GetConnection()
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at Microsoft.WebMatrix.DatabaseManager.MySqlDatabase.MySqlDatabaseProvider.TestConnection(String connectionString)
   at Microsoft.WebMatrix.DatabaseManager.IisDbManagerModuleService.TestConnection(DatabaseConnection databaseConnection, String configPathState)
   at Microsoft.WebMatrix.DatabaseManager.Client.ClientConnection.Test(ManagementConfigurationPath configPath)
   at Microsoft.WebMatrix.DatabaseManager.Client.DatabaseHierarchyInfo.EnsureLoaded()

I think I need to grant my hostname permissions for this user, but given that I don't know where the database is or how to access it via command line (there's no proper MySQL folder in program files), it's going to prove difficult.

EDIT : Found MySQL Client

Located in

Start > All Programs > MySQL > MySQL Server %version% > MySQL Command Line Client

http://forums.iis.net/t/1173668.aspx

EDIT : Grant User Priveleges

After finding the sql client, fixing the connection was done by entering the following command:

GRANT ALL PRIVILEGES ON databasename.* to ‘databaseuser’@'hostname' IDENTIFIED BY 'databasepassword';

http://31bit.com/technology/86-mysql-database/302-how-to-grant-remote-access-to-a-mysql-database

Thanks to DKNUCKLES for the port push. I was going crazy looking for config files and things for IIS express, but a port opening and granting user permissions was all it took!

EDIT: Access Denied in Wordpress install.

Now I have connected, I get access denied via wordpress. I was getting "Error establishing database connection" which was a pretty vague error.

I did a search and found a page which can test the connection:

testconnection.php

<?php
    $link = mysql_connect('databaseip_or_localhost', 'databaseuser', 'databasepassword');
    if (!$link) {
        die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully';
    mysql_close($link);
?>

I put in the correct credentials, added the page to my wordpress installation and visited it.

I got the message:

Could not connect: Access denied for user 'wordpressuser457'@'DESKTOP019-PC' (using password: YES)

It turned out that I had written the username wrong also (I was having a really long day) - it should have been wordpress457user NOT wordpressuser457.

Hate it when a dumb thing takes you ages to find.

Hope this helps anyone else looking to do the same in future.

share|improve this question

closed as off topic by Sven, Michael Hampton, MadHatter, Ward, Brent Pabst Dec 14 '12 at 13:27

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Is the MySQL server accepting remote connections? –  DKNUCKLES Dec 13 '12 at 16:54
    
I don't know because it seems to be handled internally by IIS Express within Web Matrix. There doesn't seem to be an option to change for this either. –  Ash Clarke Dec 13 '12 at 16:55

1 Answer 1

up vote 3 down vote accepted

Without any additional information my best guess is that the server is not allowing remote connections. This could be caused by any number of reasons

  1. Your colleagues computer has a firewall blocking the traffic. You can try disabling it to quickly troubleshoot
  2. The MySQL instance is not set up to allow remote connections. You can try to telnet to your friends computer and see if it allows the traffic.

    telnet 192.168.100.32 3306

  3. It may also be a permissions issue - See this link for a possible cause

share|improve this answer
    
Thanks for that - I opened up the port you specified on their machine. Now I have another brilliant error. See edit :) –  Ash Clarke Dec 13 '12 at 17:10
    
stackoverflow.com/questions/6239131/… This link should be able to assist you. –  DKNUCKLES Dec 13 '12 at 17:27
    
Thanks for your help! –  Ash Clarke Dec 13 '12 at 17:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.