How to setup phpMyAdmin on a Raspbian Stretch Lite, Nginx, MariaDB / MySQL and PHP 7 LEMP stack

The phpMyAdmin project is a solid software tool written in PHP, that can help us handle the administration of MySQL / MariaDB over the web.

phpMyAdmin Demo Server 4.7.8 demo screenshot

If you want to build your next project with a Raspbian Stretch Lite, Nginx, MariaDB / MySQL and PHP 7 LEMP stack, you may want to consider setting up phpMyAdmin as well. This post details how you can do so.


This post assumes that you had setup a Raspberry Pi running a Raspbian Stretch Lite, Nginx, MariaDB / MySQL and PHP 7 LEMP stack. If you had not done so, you may want to reference either the Raspberry Pi 3 WordPress tutorial or Raspberry Pi Zero W WordPress tutorial to setup your LEMP stack.

Using SSH to get into your Raspbian Stretch Lite

Suppose that your Raspbian Stretch Lite had gotten the IP address from your home router and you had the pi user in the system, run the following command on your terminal to SSH into your Raspberry Stretch Lite:

ssh pi@

Installing mbstring extension for PHP 7.0 on Raspbian Stretch Lite

Without the mbstring extension, phpMyAdmin is unable to split strings correctly and it may result in unexpected results.

Run the following command to install the mbstring extension for PHP 7.0 on Raspbian Stretch Lite:

sudo apt-get install php7.0-mbstring 

Creating a database user for administering your database via phpMyAdmin

The root user of MariaDB / MySQL could be using the Authentication Plugin for authentication.

The Authentication Plugin allows the user to use operating system credentials when connecting to MariaDB via Unix socket. This authentication mode cannot be used for logging into phpMyAdmin for administering your database.

Hence, we need to create a database user for us to login through phpMyAdmin. To do so, we first get into MariaDB interactive shell with the following command:

sudo mariadb

Or the MySQL interactive shell with the following command:

sudo mysql

Once you are inside the interactive shell, run the following commands to create a database user that have the privileges to administer any database in your MariaDB / MySQL server:

CREATE USER 'pmauser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON *.* TO 'pmauser'@'localhost';

Allocate a domain name for your phpMyAdmin site

The next step is to designate a domain name for accessing your phpMyAdmin site. If you already own a domain, you may want to create a subdomain out of your existing domain. For instance, I could use for my phpMyAdmin site residing on my Raspbian Stretch Lite.

Getting a copy of phpMyAdmin

Once we had decided the domain for accessing our phpMyAdmin site, we can proceed to download a copy of phpMyAdmin. You can see the list of phpMyAdmin versions that are available for download via their download page.

As of this writing, the latest stable version is version 4.7.8. Proceed to download the english version by running the following commands:

cd /var/www
sudo wget
sudo tar -xvf phpMyAdmin-4.7.8-english.tar.gz
sudo mv phpMyAdmin-4.7.8-english
sudo rm phpMyAdmin-4.7.8-english.tar.gz

Once the command completes, you should have the source codes for phpMyAdmin 4.7.8 available at the /var/www/ directory.

Configuring blowfish secret for your phpMyAdmin site

The phpMyAdmin installation directory contains a sample configuration file which we can reference for configuring our phpMyAdmin site.

To configure our phpMyAdmin site, we first make a copy of that configuration file:

sudo cp /var/www/ /var/www/

Once we had done so, use nano to open up the configuration file for editing:

sudo nano /var/www/ 

Inside the editor, look for $cfg['blowfish_secret'] and provide a 32 character long blowfish secret:

$cfg['blowfish_secret'] = '123456789012345678901234567890AB';

Once you had done so, save the file.

Configuring Nginx to proxy HTTP traffic to your phpMyAdmin site

Once we had configured the blowfish secret for phpMyAdmin, the next step is to configure Nginx to proxy HTTP traffic to it.

To do so, create a configuration file at /etc/nginx/sites-enabled/ with nano:

sudo nano /etc/nginx/sites-enabled/

And paste in the following contents:

server {

        listen 80;
        root /var/www/;
        index index.php;

        location / {
                try_files $uri $uri/ /index.php?$args;

        location ~ \.php$ {
                include fastcgi.conf;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;


Once you had created the configuration file, restart Nginx with the following command:

sudo systemctl restart nginx.service

Editing the hosts file to access your phpMyAdmin site from my work computer

Once you had restarted Nginx on your Raspbian Stretch Lite, go to your computer and add in the following contents to your hosts file:

Accessing your phpMyAdmin site from your work computer

With the entry in your hosts file, you can access your phpMyAdmin site via the domain name that you had provided (for eg. with your browser. You should be able to see the login screen:

phpMyAdmin 4.7.8 login screen

Key in the details of the database user that you had created earlier to login to the dashboard. Once you had logged in successfully, you should be able to see the following screen:

phpMyAdmin 4.7.8 dashboard screen

Setting up phpMyAdmin configuration storage

A warning message will be displayed at the bottom of the dashboard:

The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. Find out why.
Or alternately go to 'Operations' tab of any database to set it up there.

Click on the "Find out why" link and then click on the "Create" link on the next page that follows. After you had clicked on the "Create" link, phpMyAdmin will create a database instance phpmyadmin for it to store configuration information such as navigation histories, bookmarks and etc.


About Clivant

Clivant a.k.a Chai Heng enjoys composing software and building systems to serve people. He owns and hopes that whatever he had written and built so far had benefited people.

Techcoil Recommends Homepage 300x250