Using flat‎ > ‎

Using phpmyadmin with LAMP Template

posted Apr 23, 2018, 12:02 AM by Sundew Shin   [ updated May 9, 2018, 12:24 AM ]
flat provides the both phpMyAdmin and LAMP (Linux+Apache+MySQL+PHP) stack in the template library.
Using LAMP template is straight forward. You only need to decide which ports to use in host to expose the container's 80 (http) and 3306 (mysql) ports to the outside the world (with 'bridged' network option) or to just inside (with 'host') network.

Learning how to administrating MySQL database, however, requires many man-hours to learn for anyone until he/she gets to comfortable using it. Thankfully, if you are a first time user wanting a simple database back-end for your DIY project to store some timestamped sensor values to just keep pouring into, it can only take a couple of hours for acquiring the needed very basics, but I understand from own experience it can be stressful too if you only have the CLI (Command-Line Interface) option to interact with MySQL, a sophisticated database supports many commands and options to manage things. phpMyAdmin has great name value which has long history of making this process much enjoyable by providing everything in neat organized tables and drop-down menus and clickable options. It is not only easy to use but so powerful that you can easily add additional DB users, limit their access locations, backup databases, and, this list can keep going like this for awhile.


This article assumes that you already have a running LAMP container that you want to link to new phpMyAdmin container.
Here's what mine look like for now. I have one LAMP container running and reconfirm the TCP port 3306 has been exposed for access from outside container. (UPDATE: Please ignore the IP red-boxed. Thanks to a recent update, we no longer need to remember that for local access.)

Now open the phpmyadmin template screen, and we input the target MySQL database host's IP on the 'MySQL IP address' input field (UPDATE: or, leave as blank for local access.)

Next we port-map its '80' to something else (I used '81') because we already used '80' for the LAMP container.
If you want to maintain a persistent session data, you may want to either create a new volume with more recognizable name or bind to an existing host's directory. Once the container created, please remember its IP for later use also.

Open web browser, and let's check. Try username 'root' without password: 

Oops. It's failed.
Don't worry. Nothing is wrong. It's not the newly created phpMyAdmin not allowing your login, but the MySQL in the separate LAMP container. It is simply doesn't know yet our phpMyAdmin container to trust its root to be logged through with/without providing rightful password.
So let's do that.

Open the console of the LAMP container.
First type 'mysql' to enter CLI, and then input:

It means to trust it's superuser ('root') to login from the IP, (phpMyAdmin's) with the password 'your_password'
You can leave the password blank, but it is recommended. Also, you can put '172.17.0.%' to allow any access from local container network, then you don't need to let MySQL know each time you create new phpMyAdmin containers.

Now it's all yours.
Please visit for manuals and how-to.

Enjoy your projects.