0

I've been playing around with this code in-order to have ability to connect from an outside network :

The Code Below works perfect IF only i'm withing the same network :

<?php

define ('DB_USER', 'test_user');
define ('DB_PASSWORD', 'test_password');
define ('DB_HOST', '192.168.x.xxx:3306');
define ('DB_NAME', 'testing'); 
$dbc=mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) 
    OR die ('Could not connect to MySQL: '.mysql_error()); @mysql_select_db (DB_NAME) 
    OR die ('Could not select the database" '.mysql_error());;

?>

Now I have the IP address found in router settings 79.xxx.xxx.xx, but when i try to replace the 192.168.x.xxx ip, it shows the following error :

Could not connect to MySQL: No connection could be made because the target machine actively refused it.

Please Note I already have edited phpmyadmin conf file and replaced the following :

<Directory "c:/wamp/apps/phpmyadmin3.5.1/">
Options Indexes FollowSymLinks MultiViews

AllowOverride all
Order Allow,Deny
Allow from all

</Directory>

What should i do to make it work ? Please Help Thanks

Alihamra
  • 446
  • 2
  • 10
  • 26
  • As far as i know, its not possible to access phpMyAdmin from outside a local network. There must not be a router between you and the server where PMA is running, but im not completely sure about that. – Realitätsverlust Nov 12 '13 at 13:21
  • 1
    If PHPMyAdmin is running on the same machine as the database server (which is quite probably should be) it's a local IP, so: 127.0.0.1 – CD001 Nov 12 '13 at 13:29
  • Has the server the port 3306 open? If yes, then your user cannot login from outside (see @feeela answer) – Sal00m Nov 12 '13 at 13:35

3 Answers3

1

There are two options:

A) You may allow access to the desired databases from anywhere:

User | Host
———————————
Any  | %

This is widely regarded as unsafe, as anybody now could try to brute force acces your database from anywhere.

See also: How to grant remote access permissions to mysql server for user?

B) You should install phpMyAdmin on the server, where the MySQL database is installed too and limiting access to phpMyAdmin in the vHost settings to localhost. You may still access this site from anywhere using an SSH tunnel.

Community
  • 1
  • 1
feeela
  • 27,811
  • 6
  • 58
  • 68
0

You can access pma from outside a network but you have to :

  • use the public IP (79.xxx.xxx.xx)
  • forward a port from your router settings expl (79.xxx.xxx.xx:8888 to 192.xxx.xxx.xxx:3306)

Notice that if you don't have a static IP, you'll have to change your host every time that you public IP changes (or use a dynamic dns service like dyndns)

Amine Matmati
  • 303
  • 1
  • 9
-1

You cannot access a local machine of different network by the ip and the ip you have got from the router may be of you isp so to access a machine like this must have a static ip so that you can access that machine from any network

Veerendra
  • 2,540
  • 2
  • 21
  • 39
  • 1
    this is not true. a static ip is not nessecary at all, to access a machine behind a router you only need the proper port forwarding. – Gerald Schneider Nov 12 '13 at 13:30