Tutorial – Install PhpMyAdmin on your Raspberry Pi

PhpMyAdmin is a handy web interface for managing local MySQL databases, and can make database queries, management and backups easy.

In this tutorial, I’m going to talk you through installing PhpMyAdmin on your Raspberry Pi powered web server. I’m assuming you’ve got Raspbian installed, and you’ve followed my tutorial: install Apache, PHP and MySQL on Raspberry Pi.

Step 1 – Begin the PhpMyAdmin installation

From terminal, we begin by changing to the root user in terminal by entering:

sudo bash

Now we need to install the PhpMyAdmin package using:

apt-get install phpmyadmin

The package will begin installing. You will be asked which web server is installed, choose apache2.

My screenshots show purple, but you’ll see blue. I’ve already got PhpMyAdmin installed on my Raspberry Pi so had to install it on a ubuntu VM for the purpose of this tutorial – apologies for the wrong colours, but I can assure you the procedure is the same for Debian/Raspbian and Ubuntu!

Step 2 – configure for dbconfig-common

Next we’ll need to configure PhpMyAdmin’s database. You’ll see the following prompt:

When prompted, choose Yes. Next you’ll be asked for an administrative password, this is the root password that was set during the MySQL installation in the previous tutorial.

You’ll be asked to set a password for PhpMySQL. I’ve used the same password as the MySQL root password, but its up to you what you set here. Make a note of it somewhere.

That’s PhpMyAdmin installed. Next we need to change the apache configuration to allow us to use http://your.raspberrypi.domain/phpmyadmin to access it.

Step 3 – Configure Apache to work with PhpMyAdmin

We need to alter the Apache configuration in order to access PhpMyAdmin. To do this, enter the following command to alter the configuration:

nano /etc/apache2/apache2.conf

The configuration file will load in Nano. Navigate to the bottom of the file (keep pressing CTRL + V to jump page by page until you’re at the bottom of the file) and add the following new line to the file:

Include /etc/phpmyadmin/apache.conf

Save the file (CTRL + X and enter Y when prompted to save) and restart Apache2. To restart Apache, enter the following command:

/etc/init.d/apache2 restart

That’s it! You’re all installed and ready to go. Give accessing it a try by going to your Raspberry Pi’s IP address or domain name and add ‘/phpmyadmin’ to the end in your web browser, ie http://your.raspberrypi.domain/phpmyadmin. 

As always your comments are welcome, feel free to leave one below. My next tutorial will guide you through installing WordPress through terminal, and hosting your first WordPress site on your Raspberry Pi web server.

 

Ste

Web Developer living in Manchester, working for Studio Skylab (http://www.studioskylab.com). Views and thoughts are my own.

You may also like...

92 Responses

  1. ion says:

    I installed phpmyadmin on raspberry pi but left frame is not displayed (navigations.php)

    You think you can help me with this problem?
    thanks.

    • Ste W says:

      Hi Ion

      It looks like a file is missing from your installation. From terminal type:

      cd /usr/share/phpmyadmin && ls
      

      Is there a ‘navigation.php’ there? If not, I’ll zip mine up and give instruction on how to import this into your installation.

  2. ion says:

    the navigation.php file is present but i dont know why not displayed
    I looked in the html source and navigation.php file is not included

    • Ste W says:

      Are you using chrome? If you are, right click anywhere on the phpMyAdmin page and click ‘inspect element’. Click on ‘console’ and let me know if there are any errors or missing files. Failing that we could look at repairing your installation, but that wouldn’t tell us what’s not working.

  3. DrHitchcock says:

    Thanks very much for the help on this Dingleberry Pi. You rock. Who did your header image? It’s pretty rad.
    Peace,
    Dr H

    • Ste W says:

      Why thank you Dr! Glad you like the site and found it to be beneficial. I did the header image, it was done in Adobe Fireworks

  4. thivtulz says:

    I cannot log in.I never put password but i dunno why i cannot log in.With password also can not log in.Can you help.

  5. AndrewMoni says:

    I have installed apache2, mysql, php and myadmin as per your instructions (I thinbk) and got the phpmyadin screen displaying. What username and password are being asked for though – I tried pi with the password I selected for phpmyadmin and mysql and get error sannot connect to mysql … am pretty sure the error is just wrong username …. what name should i be using?

  6. Tim says:

    Thank you for the excellent tutorials; they certainly saved me a huge amount of research time.

    It is amazing what this little machine can do. 🙂

  7. Justin says:

    Got to the part where we were supposed to add

    Include /etc/phpmyadmin/apache.conf

    pressed CTRL+X and then Y and got a message

    “Error writing /etc/phpmyadmin/apache.conf: permission denied

    Is there a way to resolve this issue? I don’t know anything about Linux… But so far your tutorials have made it easy!

    • Ste W says:

      Hi there.

      Did you start with ‘sudo bash’, this essentially lets you do things with elevated privlages, so should allow you to write the file.

      Try ‘sudo nano /etc/apache2/apache2.conf’ instead of ‘nano /etc/apache2/apache2.conf’ and you should be able to make the change to the file. Any problems, leave another message and I’ll help how I can.

  8. Justin says:

    Ok this time it let me save the file but after typing in the line to restart Apache a bunch of text comes up that reads

    “syntax error on line 43 of /etc/phpmyadmin/apache.conf”

    Says the same thing probably 100 times over and over… At the bottom it says

    “Action ‘configtest’ failed.
    The apache error log may have more information.
    failed!” (red font)

    Before when I couldn’t save the file I could still reach the Apache server by going to its IP address on another computer but now it is not finding it… Because of this error I would assume… Is it how I edited the file? I did exactly as you said, key-down to the bottom of the file then insert the following

    ” Include /etc/phpmyadmin/apache.conf”

    So the last 3 lines looks something like this
    .
    .
    .
    # Include the virtual host configurations:
    Include sites-enabled/
    Include /etc/phpmyadmin/apache.conf (What I added)

    • Justin says:

      Got it all figured out! Now I’m just waiting for your next tutorial, how to install WordPress

      • Rene says:

        Just waiting for the next tutorial “how to install WordPress”

        • Paul says:

          Me too, I would love to get a website like one you have here! It’s exceptional and I hope I’ll be able to have something like this someday! Thanks for the great work so far!! Keep it coming, for all of us Ste W 🙂

  9. Justin says:

    At some point I must have accidentally went into ‘phpmyadmin/apache.conf’ and added: Include /etc/phpmyadmin/apache.conf

    Right thing to add but wrong file… Once I discovered this, deleted the line, and rebooted my pi it seems to work!!!

    My next problem is at phpMyAdmin is the username ‘pi’ I keep trying this and it produces an error #1045 I don’t recall you having me set up another username…

  10. Seth says:

    I’m getting a 403 error when trying to access phpmyadmin. Any ideas?

  11. Leon says:

    The PMA install worked out of the box for me on a Lighttpd server, but if you are having trouble with it, here are some tips for lighty users…
    http://ideamonk.blogspot.fi/2010/09/setting-up-lighttpd-phpmyadmin-etc.html

  12. Justin says:

    So i followed your tutorials, but when i go to the website “jgpallo.zapto.org/phpmyadmin” it shows nothing, just an empty page with an error saying the page could not be found.

  13. Ed-noob says:

    Perfect, followed step by step and not 1 issue!!!! I am up and running in minutes!!

  14. nick says:

    Hello,
    Thanks for the tutorial! Everything went smoothly, except it never asked me for a password. So when I try to login as the root user obviously it doesn’t work. Do you have any suggestions? Is there a way to reset the password possibly?

    Thanks,
    Nick

  15. Anton says:

    Hi,

    Thanks for an excellent guide! I’ve managed to install everything and it’s working, but I got a problem. When opening the wordpress site inside my LAN, the site loads very quick, but when outside it terrible slow. So slow that the theme isnt even loaded but only the text. The content on my other pi loads fast so it’s not the connection speed. I’ve installed using your guide on the pi in my living room running Raspbmc but that doesn’t seem to be the problem since the pages loads fast locally and the xbmc remote page is fast even outside the network. Something I could do that would speed things up, is it some kind of setting?

    Thanks a lot!

  16. Peter says:

    404 Not Found…
    Followed the instructions but when I try to direct the browser to the phpmyadmin it sys 404 Not Found.
    I can access other webpages on my domain name running on the Pi

  17. Hugh says:

    Hi there,

    I had a small problem at the “apache2 restart” step with the message:

    apache2: bad user name ${APACHE_RUN_USER}

    but I found that the sequence

    apache2 stop
    apache2 start

    worked fine and now I have phpMyAdmin working.

    Thanks for the tutorials.
    Hugh

    • mark says:

      I too found that even using root and my password did not work until i did the stop start rather than restart.

      finally working….. the key step is the sudo bash which i and others missed and that the user is root when logging in until you make your own new user.
      lots of others seem to get stuck at these same points so i dont feel too stupid

  18. Dennis says:

    I followed the tutorial, however I am getting a 403 Forbidden when I try & view /phpmyadmin Any ideas?

  19. Sam Hobbs says:

    Hi,

    This had me scratching my head for a while and was wondering if you know what’s going on!

    When I go to my-site/phpmyadmin , my browser displays what looks like some source code. To get the login page I have to go to my-site/phpmyadmin/index.php, where everything works as it should.

    Is there something I can do to make /phpmyadmin load the login page as it should?

    Thanks for all the really useful info on your site!

    Sam

  20. jp says:

    message received
    ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using │
    │ password: YES)
    when I ran apt-get install phpmyadmin.

  21. NIck says:

    Hi
    I keep getting a error saying I cannot login to MySQL server and ” connection for control user as defined in your configuration failed”

    Any ideas anyone??

  22. derc says:

    I experienced the same problem as jp. I could not log in to the mysql database although I was sure what my password was because I just entered it in the installation routine.
    I always received an error:

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

    if I used no password (mysql -u root) or

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES).

    with a password (mysql -u root -p).

    The cause of the problem was that there was no entry in the user table for the root user. The solution was to insert one:

    # stop mysql database:
    sudo service mysql stop
    # run database without acces permission control
    sudo mysqld_safe --skip-grant-tables --user=root
    # insert new user
    insert into user (host, user, password) values ('localhost', 'root', PASSWORD('mypassword'));
    # stop mysql database
    killall mysqld_safe
    # restart "normal" mysql database
    sudo service mysql start

  23. Great tutorials, many thanks.
    Just getting going with my Pi web server after creating a wordpress website recently, and wanted a stand alone test machine. All went perfectly well. WordPress on too and happily running for me.

    Thanks again.

  24. KillerSneak says:

    mysqladmin -u root password 'passwordyouwant'
    should do the trick the simple way. After that
    mysql -u root -p
    If it asks for a password everythng should be okay and you should enter the ‘passwordyouwant’

  25. elyas says:

    Great Work i followed step by step and it work perfectly.

    i have 2 questions. how can i connect to msyql databse with Navicad For Mysql.

    I enter the ip address of the pi on local network, username and password for database but it cant connect. i am using port 3306.

    How can i install FTP server so i can uplaod files with ftp software?

    Thanks for your great work.

  26. Henry van Gestel says:

    Hai,

    Nice tutorial, great work
    Can you tell me how to upgrade to example Mysql 4.1.6 and leaving this config
    as it is if possible.

    regards

  27. Bing Soewarno says:

    Hello,

    thanks for this tutorial, I did it as it is instructed, thanks again.
    Btw, I have another problem,
    Well, I have 1 raspberrypi and 1 windows server (PC) which already has mysql (phpmyadmin) inside it ( I use PC with windows os as a server).
    I need to insert data by using a python script inside the raspberrypi (I work from the raspberrypi) but the data must go to the windows server (it doesn’t work yet), the point is, inside raspberrypi only has python script to insert data and the mysql-client, and the windows server only has the mysql phpmyadmin.
    I can ping from Raspberrypi to the windows server and vice versa, meaning they are both connected each other.
    In phpmyadmin (in the PC server), under privilege menu, I already setup to letting the raspberrypi’s IP to either insert or delete the data, but it does not work yet.
    Did I miss something?
    Would you please let me know the correct setting and guide me step by step?
    Many thanks.

    Cheers,
    Bing

  28. Henry says:

    Hai, nice work.
    Have you any sugestions how to upgrade phpmyadmin on rpi?

    Thanks

  29. Philippe Luyten says:

    Is there à procédure to install on a rpi cluster?

  30. neville says:

    Thank you so much. i’d left out the “Include” line in my installation previously. now I’m also close to having WordPress running on my Pi! 🙂

  31. petergoldsborough says:

    Thanks a lot 🙂

  32. Klas Löfstedt says:

    Hi, it worked fine, but after i rebooted the pi i can’t seem to find it anymore in my searchbar. it only says “google chrome could not find raspberrypi”. is there something simple im missing here or..?

  33. johngriswold says:

    Another excellent tutorial. Use of “root” as admin user under phpmyadmin was non-intuitive to a first-timer. These details are important for us. It something trips you up, please make note of it whenever you can remember. You still get an “A”!

  34. Brian O'Donovan says:

    Really helpful, thank you

  35. michelle says:

    Thank you so much for this awesome tutorial!

  36. Lyndon says:

    Much Thanks!

  37. rajamoorthy says:

    thanks..works great for me.

  38. Tahir Ansari says:

    Thanks mate…. u saved my project

  39. localse3 says:

    I cant seem to login. i tired username as pi – root – user but nothing. is there a way to check password or reset password and username?

    • localse3 says:

      /usr/bin/mandb: can’t write to /var/cache/man/16132: No space left on device
      what does this mean? its a 8gb sd card i dont see why there is no room left.

  40. Tim Powell says:

    Worked perfectly, but I did not need the Include directive – in fact it generated a warning about overlapped alias. I removed it and it all works fine. I use apachectl -k restart to restart the server in case that’s relevant.

  41. chfakht says:

    Hi i need to insert a c++ data into MySql database , any help !!! thanks

  42. Namnodorel says:

    Thanks a lot! ^^ I tried other Tutorials, but only this worked

  43. dkreynolds says:

    Hi Ste W, Great tutorial for a command line hugger like me. I cant see, so use talking screen reader with Emulator to access pi. Everything works fine. If I can do it…

  44. April lee says:

    Hi
    I would like to ask if the phpmyadmin installed in the raspi is the same phpmyadmin on the localhost? I Want to push data from the raspi to the local host phpmyadmin database, would this code be able to do so?

  45. Sascha says:

    Thank you for this great tutorial. It worked perfectly.

  46. Torv says:

    Thanks for a nice post. Easy to follow to set up on a Pi Zero and now bookmarked.

  47. Hi Ste,

    Very nice tutorials. It works right out of the box, even with raspberry pi B2. Did you finally do your FTP and WORDPRESS tutos? Where can we find them?

    Thanks for all your efforts

    John

  48. Aday says:

    Very good tutorial! Everything works for me (raspberry 2)

    Thanks!

  49. iyed says:

    hello , thanks a lot for the amazing tutorials , can you help me with somthing , you see ai want to access my database , witch benn installed in my pc , with my raspberry pi , can i do that ??

  50. Students says:

    We’ve just used this website as a tutorial in our university lesson. It helped a lot! Thanks bro

  51. Worked perfectly for me. Thanks a lot!

  52. sunset501@gmx.de says:

    Hi,
    i accidentially closed the configuration of phpmyadmin via dbconfig-common. Is there a way to get to the configuration again?

  53. Thanks a lot, worked.

  54. Arm says:

    Excellent, well explained, and useful.
    Thanks mate 😉

  55. Sanjeev says:

    Hi,

    while configuring I am getting the error

    An error occurred while installing the database:

    │ ERROR 2002 (HY000): Can’t connect to local MySQL server through socket
    │ ‘/var/run/mysqld/mysqld.sock’ (2)

  56. rcomlan05 says:

    Hello
    I followed your article and I installed the Web server on Debian successfully.
    Thank you !!

  57. Dhyan says:

    Hello

    Thank for your very helpful tutorials.

    I installed Apache2, MySQL and PHP7.0 as you described in your tutorials.
    When I follow this installation for phpmyadmin, some packages related to php5 will be installed (dbconfig-common libapache2-mod-php5 libjs-sphinxdoc libjs-underscore libonig2 libperl4-corelibs-perl libqdbm14 lsof php-gettext php-tcpdf php5-cli php5-common php5-gd php5-json php5-mcrypt php5-mysql php5-readline). That does not make sense, when working with PHP7.0

    How to install phpmyadmin with PHP7.0 ?

    Thanks for any hints.

  58. when i enter /etc/init.d/apache2 restart
    i get restarting apache2 (via systemctl): apache2.servicewarning: Unit file of apache2.service changed on disk, ‘systemct1 daemon-reload’ recommended. job for apache2.service failed see systemctl status apache2.service and journalctl -xn for details

  59. Thank you Sir for this wonderfully explained article. This worked perfectly without any issue. Thanks again

  1. 26th July 2013

    […] hosting from your Raspberry Pi! In the next few tutorials, I’ll guide you through installing PhpMyAdmin, FTP server and Postfix. Feel free to leave your comments below. This entry was posted in […]

  2. 1st August 2014
  3. 14th November 2014
  4. 24th February 2015
  5. 25th March 2015

    […] Tutorial – Install PhpMyAdmin on your Raspberry Pi […]

  6. 25th October 2015
  7. 2nd November 2015
  8. 26th December 2015
  9. 22nd February 2016

    […] Download and install the appropriate phpmyadmin package. […]

  10. 9th April 2016

    […] Tutorial – Install PhpMyAdmin on your Raspberry Pi […]

  11. 15th June 2016
  12. 13th August 2016

    […] Tutorial – Install PhpMyAdmin on your Raspberry Pi […]

Leave a Reply