0

I am having a server running on my machine and I am calling it over the network. The Server is running fine and there have not been any problems with apache or php yet.

My database is not running on the same machine as apache but in the same local network on a server with the domain "sql.local.network.com".

Now i copied a Wordpress site onto my webserver which has been on another server in the same network, so it should work fine, since the database server is still accessable by both these webservers.

The problem now is, that Wordpress just shows the message Error establishing a database connection.

What I did was to access the database with phpmyadmin which I quickly set up on the server. This worked fine, and I was able to access the database.

Also I found a short skript:

<?php
  $link = mysql_connect('sql.local.network.com', 'user', 'password');
  if (!$link) {
    die('Could not connect: ' . mysql_error());
  }
  echo 'Connected successfully';
  mysql_close($link);
?>

This echoed Connected successfully, which means a simple mysql_connect works fine as well.

Also I am able to ping sql.local.network.com over my console and get the response 192.168.0.101.

Everything works, but the Wordpress-page.

Is there a simple solution to fix the Wordpress connection problem I am missing?

7
  • the same network, so it should work fine No it shouldn't. Check the mysql mysql -> users table, to see, where user can connect from. Maybe you need to check your firewall settings too. Commented Nov 28, 2014 at 13:39
  • but why is it possible to connect with phpmyadmin from the very same webserver then? Commented Nov 28, 2014 at 13:40
  • Ok, then you can access that. And did you set everything in the wp-config.php too? Commented Nov 28, 2014 at 13:42
  • yes I did, I just changed the adress of the webserver itself obviously, otherwise wp would redirect. Commented Nov 28, 2014 at 13:45
  • Then I have no idea. Commented Nov 28, 2014 at 13:47

1 Answer 1

1

Check the Privileges tab in phpmyadmin and look at the host column. If it's set to "localhost", then that dataabase user can only access the database from the same server as the database. To access remotely, change it to either "%" for any server or to the IP of the server you're trying to connect from.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.