MySQL Access From Outside
To allow direct client connections to MySQL from outside systems…
Edit MySQL’s configuration file -
C:\WampDeveloper\Config\Mysql\my.ini
Change MySQL’s IP binding from “127.0.0.1″ to “0.0.0.0″:
bind-address = 0.0.0.0
This will allow MySQL to listen on all the assigned IPs of the system (including 127.0.0.1), such as the LAN IP and possibly the Public IP (if you’re not behind a Router).
Then you’ll need to -
Update the MySQL user account’s (the account to be allowed access to from outside) “Host:” field to either: “%” (which means it can be accessed from ANY IP) or to the specific outside system’s IP address. This part has nothing to do with the local IPs or the server’s public IP… It’s all about the client IP. You can do this via phpMyAdmin (Users Tab), or via the MySQL Shell.
* This is only done to allow direct-to-MySQL connections from outside, and is NOT done for accessing phpMyAdmin from outside. In the later case phpmyadmin always accesses MySQL locally, so the MySQL account it uses must have “Host: 127.0.0.1″ and “Host: localhost” (via a second account with the same name). The “Host:” value is what MySQL checks when a connection is established to it (directly, or via a local script such as phpmyadmin), and if it does not match, access is not granted.
* Remmember to set the correct Windows Firewall rules to allow incoming port 3306 connections. Windows Firewall will block these by default.
phpMyAdmin Access From Outside
To allow login access to phpMyAdmin from an outside system…
If this MySQL account is just being used to access the \phpmyadmin URL from outside, and is not a MySQL client connecting directly to the MySQL server via port 3306, you’ll need to give it access to \phpmyadmin by editing phpmyadmin’s config.inc.php file and in the access list adding in “allow mysql-account-user-name from all”. This will allow that account to login to \phpmyadmin from any outside IP.
For this case, you do NOT need to modify MySQL’s (my.ini) “bind-address = 127.0.0.1″, as phpMyAdmin is a local script that accesses MySQL locally regardless of who is using it from where.
Edit phpMyAdmin’s configuration file -
C:\WampDeveloper\Tools\phpMyAdmin\config.inc.php
Insert access permissions for the username and the IP address (or IP range) allowed, into the array:
/* * phpMyAdmin does no user management and will not cross-check the MySQL account's host with the incoming connection's ip/host */ $cfg['Servers'][$i]['AllowDeny']['order'] = 'deny,allow'; $cfg['Servers'][$i]['AllowDeny']['rules'] = array( 'deny % from all', // deny everyone by default, then - 'allow % from 127.0.0.1', // allow all local users // allow user:root access from these locations (local network) 'allow root from localhost', 'allow root from 127.0.0.1', 'allow root from 10.0.0.0/8', 'allow root from 172.16.0.0/12', 'allow root from 192.168.0.0/16', // add more usernames and their IP (or IP ranges) here - // ... );
* You should: create a new MySQL account to use for connecting from outside, give it specific permissions only on databases it should be able to read/write, try not to reuse user:root, nor change any existing accounts.
* The WampDeveloper.xml configuration file should always use “Host: 127.0.0.1″ as the WampDeveloper application is always performing a local connection to MySQL. The user-name (usually “root”) used here will also need to have the default “Host: 127.0.0.1″ field setting under it’s MySQL account, as that is where the connection is coming form. WampDeveloper.xml defines the account info to use by the WebApps Tab when installing a new webapp and is not related to anything above.