Sunday, November 27, 2016

Enable ssh tunnel to access phpmyadmin on google cloud

Enable ssh tunnel to access phpmyadmin on google cloud

Here is a hint for those who are trying to connect to you MySQL database server using phpMyAdmin.

It is assumed that you have already setup your Google Cloud server, installed Apache, MySQL and phpMyAdmin.

Opening up phpMyAdmin for access from any machine is not a safe thing to do. Again, adding your IP to the phpMyAdmin.conf everytime is not advisable either.
Browser screen when accessing phpmyadmin before creating the ssh tunnel
Result when accessing phpmyadmin before creating SSH tunnel

The best thing to do is to create a tunnel connection to your server, using the following instructions.

When you access phpmyadmin before creating the tunnel, shows you an error message similar to the one on the left.

So, open the Cloud SDK Shell.

Then create a tunnel using the following command.

--zone <ZONE-WHERE-YOUR-INSTANCE-IS-LOCATED--ssh-flag="-L" --ssh-flag="8888:localhost:80"

eg., gcloud compute ssh myCentos-1 
--zone us-central1-b --ssh-flag="-L" --ssh-flag="8888:localhost:80"

Note: You will be replacing the words in bold above with your relevant server name and zone name.
phpmyadmin login screen is shown when accessing phpmyadmin after creating the ssh tunnel
phpMyAdmin Login Screen shows after successful creation of ssh tunnel

After doing the above, open phpMyAdmin from your browser by typing the address

Voila, you get the login screen!

No comments:

How to not print columns on display while printing on paper

Many of you may or may not be aware of a javascript code that is capable of printing page content. We had created a report which looked s... Registered & Protected DWYE-NHTO-NBNH-7FFM