We love phpMyAdmin here at TBO (The Barton Organization). We’ve written a few great articles about phpMyAdmin. Our most popular being phpMyAdmin SSL; take a look at that one, but only after you read this article.
phpMyAdmin SSH Tunnel
Managing servers can be a pain. That’s why people hire Development companies like us. A tip we’re willing to share, or a way of doing something, is using phpMyAdmin to manage multiple database servers. phpMyAdmin has a config.inc.php file. That file has the ability for servers to be added to it. So let’s add a server to it:
$port = 3307;
/** example server 1 **/
$cfg['Servers'][$i]['verbose'] = 'myseowebsite.com';
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['port'] = $port++;
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['compress'] = FALSE;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['hide_db'] = '^performance_schema|information_schema|mysql|sys$';
What that does is allow a server to show up in the server list. We increment a $port variable so that we can just keep adding servers to it.
Then what we are going to do is called port forwarding. This example is going to be way complicated for a non-developer. So if you read any of this without understanding anything, my apologies. Maybe read one of our branding / marketing posts.
ssh -fNL 3307:localhost:3306 myuser@MY_REMOTE_HOST
You see where it says 3307? That port number should match up to the server port in your config.inc.php file. You can choose any user you want that has access to the web server. For this to go smoothly, you’re going to want to have keyless entry into your server. Otherwise, it’ll ask for your password.
You just learned how to manage remote MySQL servers with phpMyAdmin. What makes this so great? Well, what it does is it saves you the time of having to install phpMyAdmin on any of the servers, and you do not have to worry as much about keeping phpMyAdmin updated. You update locally, secure it locally, then manage the remote servers. This saves you a LOT of time.