Accessing remote databases using phpMyAdmin running locally

August 17, 2017

#Linux #MySQL #PHP #phpMyAdmin #Raspberry Pi #WordPress

I believe it makes a lot of sense to only ever use a local copy of the phpMyAdmin client typically used to manage MySQL databases – ie to access live servers remotely via the local client. Installing phpMyAdmin on an actual server creates an additional unnecessary potential vulnerability – another login point.

I have the phpMyAdmin client installed on the Raspberry Pi which is use as a local network web server for development. I can then access the client interface from any machine on the local network and use phpMyAdmin to manage the remote databases.

There are plenty of guides explaining this online. In brief – two steps involved in setting this up to access remote databases:

  1. Create new entries for each of the remote databases in the config.inc.php file.

  2. Use SSH tunnelling to create a secure connection from the local machine to the remote host. Eg: sudo ssh -fNL 3307:localhost:3306 sudo_user@REMOTE_HOST_IP_ADDRESS

NB: I found that the repository version of phpMyAdmin for my Linux distribution was always somewhat out of date. I decided, instead, to manually install phpMyAdmin under the local web server’s default root directory and to access it directly from there. I probably wouldn’t have wanted to do that if I were not running it from behind a NAT router.



Show All Posts