简体   繁体   中英

Database is there but Wordpress cannot establishing a Database Connection

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM