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.
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.
You will need the pieces of equipment listed below to complete this Raspberry Pi PHPMyAdmin tutorial.
Raspberry Pi 2 or 3
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.
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.
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.
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.
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
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 )
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.