How to Install PHPMyAdmin on the Raspberry Pi

In this Raspberry Pi PHPMyAdmin tutorial, we will take you through the steps on how to install the popular MySQL administration tool PHPMyAdmin to your Raspberry Pi.

Raspberry Pi PHPMyAdmin

For anyone who doesn’t know, PHPMyAdmin is a free tool that has been designed to allow for easy administration of MySQL. It is hugely popular and used in a lot of web server environments throughout the world.

You will find that installing Raspberry Pi PHPMyAdmin is very easy to do and won’t take long. You to need have a web server on your Raspberry Pi set up and ready to use.

Learning how to use PHPMyAdmin is quite daunting for beginners. I recommend checking out some tutorials if you’re completely new to managing databases.

If you haven’t already installed a web server, you can learn from our guide on installing Apache or our guide to installing NGINX.

Equipment List

You will need the pieces of equipment listed below to complete this Raspberry Pi PHPMyAdmin tutorial.

Recommended

Raspberry Pi 2 or 3

Micro SD Card

Power Supply

Ethernet Cord or WiFi dongle (The Pi 3 has WiFi inbuilt)

Optional

Raspberry Pi Case

Setting up PHPMyAdmin on the Raspberry Pi

As with all of our  tutorials, we will be using the latest version of Raspbian to complete this tutorial.

First, make sure that you followed the previous tutorial on installing a web server with PHP support. You will also need to install and setup MYSQL.

You will need to have the password you set up for the root MYSQL account. If you don’t have this, you will not be able to install PHPMyAdmin.

1. To install the PHPMyAdmin package to our Raspberry Pi, we need to run the command below.

sudo apt install phpmyadmin

2. PHPMyAdmin will now begin to install to your Pi. It will require your input on various steps along the way. You will be presented with a screen asking the type of web server you want it to run off.

Select the “apache2” option by pressing SPACE and then ENTER. Select this option even if you are using NGINX as we will configure that ourselves latest on.

3. Next, we will need to configure PHPMyAdmin to connect to our MYSQL server. We will also need set up some details so that we can log in to the PHPMyAdmin software.

To do this select “<Yes>” at the next prompt.

Raspbian PHPMyAdmin setup

4. It will now ask you to set a password for PHPMyAdmin itself. It is best to set this password to something different to your root SQL password. Doing this will help secure the server.

This password is what PHPMyAdmin will use to connect to the MySQL server.

5. With the PHPMyAdmin installation process complete, there is one last thing we need to do. PHPMyAdmin by default will block you from logging into the PHPMyAdmin interface using the “root” user.

Instead, you will need to create a new user if you wish to create and access data tables within PHPMyAdmin.

To do this, we will need to first login to the MySQL command line interface using the “root” user with the password you set up.

sudo mysql -u root -p

6. Now run the command below to create a user and permit it to access all databases on the MySQL server. Remember the details you enter here as you will use these to log in to PHPMyAdmin

Make sure you replace “username” with the username of your choice.

Also, replace “password” with a secure password of your choice.

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

7. You can exit out of the MySQL command line interface by typing “quit” in the terminal.

Once done you can proceed to configure PHPMyAdmin for Apache or NGINX.

Raspberry Pi PHPMyAdmin Thumbnail

Configuring Apache for PHPMyAdmin

1. Before we can load the PHPMyAdmin interface on our Raspberry Pi, we will need to make some configuration changes to Apache.

To get started, we need to edit the “Apache2.conf” file, we can do this by entering the following into the terminal.

sudo nano /etc/apache2/apache2.conf

2. Now we need to add the following line to the bottom of this file.

This line will include PHPMyAdmin’s configuration and allow it to be loaded in and listened to by Apache.

Include /etc/phpmyadmin/apache.conf

Once done we can save and exit by pressing CTRL + X and then pressing Y then ENTER.

3. Now we need to restart the Apache service on our Raspberry Pi by running the command below.

We need to do this to flush out its current configuration and make it load in our modified file.

sudo service apache2 restart

Configuring NGINX for PHPMyAdmin

1. To setup NGINX to work with PHPMyAdmin, we need to do is create a link between the phpmyadmin folder and our root HTML directory.

To do this, we need to run the following command on our Raspberry Pi.

sudo ln -s /usr/share/phpmyadmin /var/www/html

Accessing PHPMyAdmin

1. You should now be able to access your Raspberry Pi’s PHPMyAdmin interface from a web browser.

To test this, go to the following address in your favorite web browser. Use the user you created earlier on in the tutorial to log in. Do not use your root user as this is disabled by default.

Remember to replace the IP Address with your Raspberry Pi’s IP Address. (If you don’t have it, run the hostname –I command on your Raspberry Pi )

http://192.168.1.108/phpmyadmin

Raspberry Pi PHPMyAdmin Interface

At this point, you should now have PHPMyAdmin up and running on your Raspberry Pi.

You will find this tutorial to be very handy if you decide to set up heavy database applications or websites. For example, WordPress is very reliant on a database, so being able to access and manage it is a must.

I hope that you have enjoyed this Raspberry Pi PHPMyAdmin tutorial and if you run into any issues, feel free to drop a comment below.

8 Comments

  1. Avatar for Dan Hall
    Dan Hall on

    Awesome !!

    Thank you so much for sharing. very straight forward. and absolutely no problems following your direction.
    One question, how do I ftp into our new server.??

    Thanks again
    Dan H.
    Arlington, Texas

    1. Avatar for Gus
      Gus on Editor

      Hi Dan,

      Our FTP tutorial should help you setup FTP for the Raspberry Pi. You may need to also tinker with file permissions if you find you cannot write to certain files/folders.

  2. Avatar for peter kopinich
    peter kopinich on

    I installed the Webserver – NGINX, PHP 7.3 and MariaDb, with PHPMyAdmin on an “old” B+ Raspi, everything seem perfect…..let me try and thank´s a lot for your tutorial.

    See you ;-))

  3. Avatar for Joaquin
    Joaquin on

    Hi,
    I have followed the instructions of your “Build your own Raspberry Pi NGINX Web Server” article and “MariaDB (MYSQL) installation tutorial” and they work perfectly. Now, I’m trying to install PHPMyAdmin following this guide but I don’t understand why it’s necessary to edit the apache2.conf file and, after that, restart the apache service. In fact, and in my case, the file apache2.conf don’t exist in my system and, when I’m trying to restart the service I obtain the message “Failed to restart apache2.service: Unit apache2.service not found.”
    I’m sure I’m doing something wrong, but I can’t see what so, can you give some help, please?
    Thanks in advance,
    Joaquin.-

    1. Avatar for Emmet
      Emmet on Editor

      Hi Joaquin,

      If you are using NGINX then you should not do the “Configuring Apache for PHPMyAdmin” section and instead follow the “Configuring NGINX for PHPMyAdmin” section that is directly after that.

      Cheers,
      Emmet

    2. Avatar for Joaquin
      Joaquin on

      Thank you very much, Emmet.

      Best regards,

      Joaquin.-

  4. Avatar for Mu.Pathma
    Mu.Pathma on

    Hi, Thanks for the details , you might wanted to add “sudo mysql_secure_installation” step to add protections, for development stage this might not needed, for production usage this is needed.

    1. Avatar for Gus
      Gus on Editor

      Hi,

      Thanks for the feedback, but this tutorial is purely for installing PHPMyAdmin. In our MariaDB (MYSQL) installation tutorial we advise running that command.

Leave a Reply

Your email address will not be published. Required fields are marked *