Question

I have a webshop running on a windows 2008 R2 server that can be accessed on a client PC in the same network. It's working fine, but now I need to get the database from another windows 2008 server instead of running it on the same machine.

I've already installed WAMP on the new server, imported the database into phpmyadmin and opened port 80 for the firewall. In my connection file for the webshop I've changed the HOST to "192.168.0.17:80" (IP adress of the DB server).

I can still connect to the shop and use anything that doesn't use a database, but when I do need the database it loads for a while and it shows me a timeout error.

Pinging to the database from the Webhost server works. Am I missing something?

Edit: I can now access PHPMyAdmin from the Webserver through "192.168.0.17/phpmyadmin". What would I have to enter in the PHP file to connect it to the database?

Était-ce utile?

La solution

If you have phpMyAdmin and the webserver running on 192.168.0.17, and the database on, say, 192.168.0.20, then two things need to happen to allow phpMyAdmin to access the database.

  1. MySQL needs to allow users to connect from other machines. By default, this usually is permitted; I'm not particularly sure what changes WAMP might make. If you've created users with host 'localhost', they won't work and you'll need to increase their permissions by modifying the host or creating a new similar user. The usual disclaimers apply about backing up first.
  2. phpMyAdmin needs to be configured to look at the new MySQL server instead of localhost. Open up config.inc.php and edit or change the $cfg['Servers'][$i]['host']... line to read $cfg['Servers'][$i]['host'] = '192.168.0.20';

Once you've done that, you can open up the phpMyAdmin on your webserver and it should now attempt to connect to the other server that now has your MySQL server installed.

I've already installed WAMP on the new server, imported the database into phpmyadmin and opened port 80 for the firewall. In my connection file for the webshop I've changed the HOST to "192.168.0.17:80" (IP adress of the DB server).

I'm not sure what this means. Your web application (what I presume you mean by "webshop") does need to know where the new database is, but port 80 is for web traffic, not MySQL connections (which are port 3306 by default).

One more little note: In the title you mention "an external phpmyadmin", but in the case of networking as you describe "external" generally means "outside the local network" (which in turn generally means "anywhere on the internet"); I think you mean another machine on the same network which would be internal to your network.

Edit I realized I'm more confused about your question than I thought, because you wrote

Edit: I can now access PHPMyAdmin from the Webserver through "192.168.0.17/phpmyadmin".

Which doesn't make sense. I thought you have two servers, the webserver (which runs your web application and phpMyAdmin) and the database server. I am starting to suspect the webserver is actually 192.168.0.17, in which case you've correctly configured your phpMyAdmin to access the new MySQL server, so all you should have to do is update your web application to the proper IP address (without a port!); simply matching what you have in phpMyAdmin's config.inc.php. So instead of 192.168.17:80 as the host in your web application, you want the same hostname or IP address that phpMyAdmin is using to connect to. You can find that on the main page as well under the "Database server" section.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top