Installing phpMyAdmin on Mac OS X Lion

This article is part of Django Installation on Mac OS X Lion

Mac OS X by default ships with Apache web server which we will use to install (configure) phpMyAdmin to manage MySQL server installed previously on Mac OS X 10.7 (aka Lion). At the end of this step-by-step tutorial, you should be able to access phpMyAdmin by opening http://localhost/phpMyAdmin in your preferred browser.

In this tutorial we will be using Terminal to move files around and edit/create files using command line.

Installing phpMyAdmin

  1. Start Apache if it’s not already running (You can check by running command “ps -ef | grep httpd” in terminal)
    1.  Open System Preferences and Click Sharing

      Start Apache Mac OS X

      Start Apache Mac OS X

    2. Check Web Sharing Checkbox which should start web server (Apache) on your Mac
    3. Open http://localhost in browser and you should see default page (on mine it just says “It Works” in H1 Tag)

      Mac OS X Web sharing Homepage

      Mac OS X Apache Homepage

  2. By default, PHP module is not activated. Uncomment the line ”LoadModule php5_module libexec/apache2/” in file “/private/etc/apache2/httpd.conf” to enable PHP on Mac OS X Apache web server. Default PHP version is PHP 5.3 (PHP 5.3.6 to be precise)
  3. Download phpMyAdmin (Latest version at the time of writing this is from phpMyAdmin Site. Download page has quite a few options in terms of language and compresssion formats, so download the most relevant language pack and compression format you are comfortable with. (I downloaded, please note your version may be different )
  4. Open Terminal and Extract downloaded package to /usr/local/ by running command  “sudo unzip -d /usr/local/
  5. Rename phpMyAdmin- to phpMyAdmin by using command “sudo mv /usr/local/phpMyAdmin- /usr/local/phpMyAdmin” in Terminal
  6. Switch to phpMyAdmin directory using “cd /usr/local/phpMyAdmin” to create phpMyAdmin config file
  7. By default file does not exist but phpMyAdmin ships with sample config which we can use. Copy to using “sudo cp
  8. Edit using your favorite editor (I prefer vi) and change $cfg['Servers'][$i]['host'] = ‘localhost’; to $cfg['Servers'][$i]['host'] = ’′;
    *Well it sounds stupid because localhost and are same in networking world but phpMyAdmin won’t let you (At least me) log in without this change and keeps throwing error “#2002 Cannot log in to the MySQL server
    **If your MySQL is running on a different host/port, you can change them in this file
    ***You can also use setup wizard offered by phpMyAdmin to configure phpMyAdmin further
    ****You can also add random blowfish secret to to encrypt your session cookies.
  9. Configure Apache to enable /phpMyAdmin
    1. Create phpMyAdmin apache config file with below text in bold in /etc/apach2/other/ directory using your favorite editor  “sudo vi /etc/apache2/other/phpMyAdmin.confAlias /phpMyAdmin /usr/local/phpMyAdmin
      <Directory /usr/local/phpMyAdmin>
          Options Indexes
          Order allow,deny
          Allow from all
  10. Restart Apache by typing command sudo apachectl restart in terminal
  11. Open http://localhost/phpMyAdmin in your browser and you should see phpMyAdmin Login Page

    Mac OS X phpMyAdmin Login Screen

    Mac OS X phpMyAdmin Login Screen

*Note Default phpMyAdmin does not allow you to login with empty passwords, you can change this behaviour but it is highly recommended to have password for mysql server accounts.

91 thoughts on “Installing phpMyAdmin on Mac OS X Lion

  1. Pingback: Notes about Setting up My LAMP | Sam's PHP How-To

  2. @Aaron

    You said: “the line spacing on that last bit is confusing. when I copy and pasted it into terminal, vim opened and the first line was: rectory /usr/local/phpMyAdmin>
    Thats where the confusion began, and this tutorial lost its luster.”

    Vim is a little different from most text editors. You have to type “i” to enter insert mode, then you can start typing. The first letter “i” in the test you copied in is the one in “directory”, so that’s where you entered insert mode, and only stuff after that pointed was inserted. Then to save changes, you typ Esc to leave insert mode, “:wq”, which is a command that means “write and quit”, or just “:w” to write the file and continue working – a little like cmd-S.

    Way to find a workaround, though.

  3. Really helpful but when I run “sudo apachectl restart” in terminal at the end I get the following error:
    “/usr/sbin/apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument”

    Any ideas?
    Thanks everyone.

  4. Hi all. Thanks for this, its been really useful but when I try to run “sudo apachectl restart” in Terminal I am getting the error “/usr/sbin/apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument”

    Any ideas?

  5. This totally DOES NOT WORK. Running current Lion Server 10.7.3. Followed the instructions, including step 9 with corrections to the letter. Followed the suggestions to place phpMyAdmin.conf file in various locations. When moving that file into /etc/apache2/sites it completely stops the web server from loading the default pages – in fact any pages.

    Q1 – has anyone gotten this to work with Lion Server 10.7.3 – if so please post where you loaded and what parameters you used.

    Q2 – someone suggested moving the entire installation to /library/server/web/data/sites/default
    which could be possible – HOWEVER – do you then need to move (where to) phpMyAdmin.conf to somewhere and change the /ust/local/phpMyAdmin line in that file to reflect the directory above????

    While this post has been helpful to a degree – it’s extremely frustrating.

    And, yes, MySQL is working fine, and yes PHP is enabled, and yes we can currently serve web pages, and yes, yes, yes. Thanks.

  6. Step 9 is somewhat confusing… for me it works by adding below lines under phpMyAdmin.conf under /etc/apache2/other folder:

    Alias /phpMyAdmin /usr/local/phpMyAdmin

    Options Indexes
    Order allow,deny
    Allow from all

    This is indeed a good tutorial.

  7. Everything works fine and I can login (thanks to Michael on August 17, 2011 at 4:59 pm for password bit) but once I’ve logged in, I just get a blank screen.
    Complete newbe to MySQL and PHP (although long term IT and Apache, Perl etc on Solaris, not Mach).

    What should I see?

    OSX 10.7.4, Safari 5.1.7

  8. Well, still not figured that out, but I installed MAMP and that appears to be working

  9. Two issues:

    1) I had this alias, and could see the login page… but got a server error 500 when logging in… I had to actually COPY this directory to my docroot.


    > Alias /phpMyAdmin /usr/local/phpMyAdmin
    > (Directory /usr/local/phpMyAdmin)
    > Options Indexes
    > Order allow,deny
    > Allow from all
    > (/Directory)

    2) I set my mySQL root password per Michael’s note..

    But it won’t let me login using that root + password in the GUI.

    WHY NOT?

    > Michael on August 17, 2011 at 4:59 pm said:
    > 1) Open up a terminal window
    > 2) At prompt, type: mysql -u root
    > 3) At mysql prompt type: update mysql.user SET Password=PASSWORD(‘yourpassword’) WHERE User=’root’;

  10. Hey I had some problems with this and this is my explanation and what I did…

    What was happening for me was the default folder OSX Lion is running cannot see the phpMyAdmin folder. Try these series of steps to see if they work after completing the ones above without success…

    cd /Library/Server/Web/Data/Sites/Default

    ln -s /usr/local/phpMyAdmin phpMyAdmin

    The first command is the default web route that apache seems to be using to look for files. The second command makes a symbolic link between a dummy phpMyAdmin folder created with that link and the original phpMyAdmin folder with all the files in it so if the original phpMyAdmin is not in /usr/local just use the correct path

  11. Let me just mention … if ..

    cd /Library/Server/Web/Data/Sites/Default
    doesnt work as the home directory go to wherever the DocumentRoot of wherever the Apache server is looking and cd into there. You can check to see if there is an index.html page that it is running to see if you are in the right place

  12. I get this error…

    Failed to read configuration fileThis usually means there is a syntax error in it, please check any errors shown below.

  13. Awesome… it works for me in the first try though for less experienced developers yes step 9 can be confusing as code lines are not separated in the post.

  14. I had the same problem that the url localhost/phpMyAdmin didn’t work but i just make one change at nr 9 and i fixed the problem

    Alias /phpMyAdmin /usr/local/phpMyAdmin
    (Directory /usr/local/phpMyAdmin)
    Options Indexes
    Order allow,deny
    Allow from all
    Allow from

    That was it remember to type the url with capital letters not phpmyadmin but phpMyAdmin

    Greets Jay

  15. I get:

    #2002 Cannot log in to the MySQL server

    followed by:

    Failed to read configuration fileThis usually means there is a syntax error in it, please check any errors shown below.
    Failed to read configuration fileThis usually means there is a syntax error in it, please check any errors shown below.
    Failed to read configuration fileThis usually means there is a syntax error in it, please check any errors shown below.

    Started over and followed the instructions, including several of the variations shown in the comments.

    Same result.

    I assume either or /etc/apache2/other/phpMyAdmin.conf could be the “conf” file mentioned in the error message. (Stupid phpMyAdmin – doesn’t tell you the PATH of the file that’s creating the problem!!)


  16. Great tutorial !!! It works right away in my Mac with osx Lion. Thanks !

  17. I followed instructions but now the webserver (under sharing prefs) won’t start.

    Anyone knows this problem and a solution?

  18. Thankyou, you were right about : $cfg['Servers'][$i]['host'] = ’′;
    i was trying to login to phpmyadmin, with $cfg['Servers'][$i]['host'] = ‘localhost’; but was getting error 2002…
    your blog helped me…

  19. Impossible with Safari latest version (OsxLion) to have Phpmyadmin worked – I get an Blank page after login…

    With firefox, everything is working well…
    Strange …

  20. nice explanation! worked perfect on the first run. appreciate it. (didnt have to change to just left localhost)

    got “The mcrypt extension is missing. Please check your PHP configuration.” warning at the bottom tho.

  21. I simple copied the phpadmin folder to my document root folder, which is displayed in the web panel of server manager (Library/server/web/data/sites/default)
    The only file I had to change was the ‘’ file in the root of the phpmyadmin folder. I replaced ‘localhost’ with ’′

    $cfg['Servers'][$i]['host'] = ’′;

    Just make sure PHP is working first and that you can log into MYSQL as root with a password.

    Everything works fine.

  22. If I follow instructions I find my Web Sharing status changes from On to Off if I have the phpMyAdmin.conf in the /apache2/other folder.

    As soon as I remove it I can change to On and the “http://localhost/” link shows “it Works!” but phpmyadmin does not work.

    Any ideas?

  23. As soon as I follow step 9 and create the file I cannot start apache from System Preference Sharing by checking Web Sharing, I just get a dash in the check box that goes blank after a second. If I delete the file phpMyAdmin.conf file from the other folder it goes back to normal and I can check Web Sharing. Not sure what I am doing wrong here.

  24. OK I retyped the phpMyAdmin.conf file and now it works find, but when I open the browser to http://localhost/phpMyAdmin I don’t see a login window. Instead I see the Index of /phpMyAdmin with all the files. Need some help here.

  25. OK I re-edited my phpMyAdmin.conf file and now I can start and stop file sharing from my preferences. However when I open http://localhost/phpMyAdmin I don’t get a login page, I just see the Index of /phpMyAdmin with all the files below.

  26. OK I re edited the phpMyAdmin.conf file and now I can start and stop apaches from the my preferences by checking Web Sharing. However when I open the browser to http://localhost/phpMyAdmin I don’t see a login page, instead I see Index of /phpMyAdmin with all the files below. What do I need to do to fix this?

  27. OK finally got this working by adding another line to the file in the
    /usr/local/phpMyAdmin directory:


    Now when I bring up http://localhost/phpMyAdmin in the browser I get the login window. My password does not seem to for though. will need to work on that.

  28. finally got this working. Problem was that nowhere in instructions for mySQL did it say how to set up username and password from terminal. Once I did that everything worked although I got a warning about not having a crypt extension installed.

  29. You, sir, are a LIFE SAVER. I fought with the setup for a good hour before I found this page and the “change localhost to″ instruction. Thank you!!

  30. Well… After reading the entire topic and comments… I just “dived” in… And ok.. Some strong coffee and the manual… It worked!!! Super – I am so excited!
    I normally use asp and access… But this is so far better! Thx to all

  31. I definitely think all above (or below) comments are out of place. This is the best post I have ever read because it works perfectly. I have only skipped step 8 since in my machine works perfectly with localhost instead of It took me just five minutes to get it working with this tutorial.

  32. Installing phpMyAdmin on My Mac OS truly F*** my mind. Thanks a lot you really make it so easy. How could I make such a silly mistake any way now the problem is solved and all credit goes to you man.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>