How to prevent access to phpmyadmin (MySQL database) using web browser from any computer on LAN (except the server)

StackOverflow https://stackoverflow.com/questions/20803234

Question

I have a computer lab with 21 computers connected through LAN
LAN server with IP - 192.168.0.1

I have Online Examination s/w running on all the client computers  
That s/w is developed using vb.net having MySQL database.  
(Of course the database is at the server only i.e. @ 192.168.0.1)

What i want ?:
I want to prevent users of client machines from accessing MySQL database by using their web browser like this-

http://192.168.0.1/phpmyadmin

P.s. - MySQL database must only be accessible through Online Examination s/w only.

Was it helpful?

Solution

The easiest way to secure PHPMyAdmin: Set auth_type to http in your config.inc.php and give an appropriate MySQL username and password to all authorized people. That way anyone can access PMA from anywhere in the network, but only authorized people can actually use it.

However, to do exactly what you're asking, you'll need to modify the Apache configuration on the server hosting PMA so that it denies HTTP connections to the PMA port, something like this:

<Directory "/path/to/PMA">
...
Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1, 192.168.0.1
</Directory>

This isn't a very secure configuration, so you might want to do this in conjunction with the other security suggestion above.

This suggestion is only for PhpMyAdmin, and won't affect your Online Examination software. If that works before you make these changes, it should work afterward too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top