Installing phpMyAdmin on Mac OSX 10.9 Mavericks & 10.8, 10.7, 10.6

To interact with MySQL by instead of using the  command line, phpMyAdmin comes to the rescue, to get it running as part of your local development set up on OS X, a couple of steps need to be done. phpMyAdmin is a browser application that interacts with the underlying mysql data.

These steps will work on Mac OS X 10.9 Mavericks, OSX 10.8  Mountain Lion, 10.7 and 10.6 Snow Leopard.

Preparing for phpMyAdmin

Download the latest version now at version 4.something phpMyAdmin, the english.zip should be sufficient, after the file is downloaded unzip it and move it to your personal web sharing folder, this will either be “/Users/username/Sites” directory or other web root folder such as “/Library/WebServer/Documents/“.

Rename the folder from “phpMyAdmin-4.0.0-english” to “phpmyadmin“.
The rest of the tutorial assumes that you have already mysql set up with a mysql root user and password enabled if not then please follow that process first.

The login address for phpMyAdmin is going to be http://localhost/~username/phpmyadmin/ or http://localhost/phpmyadmin/ depending on your web root directory, but  before this will work correctly a few steps need to be done namely addressing the MySQL socket error and configuration file set up:

a) Launch /Applications/Utilities/Terminal to fix the mysql 2002 socket error by entering the following commands:

sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Basically this is making an alias to where phpmyadmin thinks the mysql.sock is and where it actually is.

b) In the phpmyadmin folder in your web root make a new directory named “config”.

 mkdir ~/Sites/phpmyadmin/config

c) Give Others “write“permissions to the “/phpmyadmin/config” folder either through Get Info or a ‘chmod o+w‘ in Terminal.

 chmod o+w ~/Sites/phpmyadmin/config

Installing phpMyAdmin

Older Safari browser currently has issues with the installation, blank screens?? Upgrade to Safari 6 or use either Chrome or Firefox.

Now we are ready to run the set up in the browser by going to:

http://localhost/~username/phpmyadmin/setup/

or

http://localhost/phpmyadmin/setup/

phpmyadmin-set-new-server

The new server to be configured is the localhost, click new server and then the only other configurations are the local mysql root user and the password in the Authentication tab.

 

phpmyadmin-set-new-server-mysql-password

Add in the username, by default “root” is assumed, add in the mysql root password (this is the password for mysql not for the OSX admin account) , click on save and you are returned to the previous screen.

 

 

phpmyadmin-save-config

Make sure you click on save, then a config.inc.php is now in the /config directory, move this file to the root level of /phpmyadmin and then remove the now empty /config directory.

 

Now going to http://localhost/~username/phpmyadmin/ or  http://localhost/phpmyadmin/will now allow you to interact with your MySQL databases.

phpmyadmin-4-no-frames

Mcrypt missing extension – If your applications don’t require the mcrypt  extension there is no need to worry about it missing as reported in phpMyAdmin, if you do need to install it follow the guide here on mcrypt extension in Mavericks.

Upgrading phpMyAdmin is an easy task just grab the latest version from the phpmyadmin website and replace your older phpMyAdmin directory in your web shared folder apart from the “config.inc.php” file – make sure the config.inc.php is kept and put it back in the new directory.

  • Dan White

    Worked great! Did I read somewhere that “End of Line” should be changed to “UNIX / Linux (\n)”? to prevent issues?

    Yes, I found it in the phpMyAdmin Documentation. Is that what this excerpt means:

    “Warning for Mac users: PHP does not seem to like Mac end of lines character (“\r”). So ensure you choose the option that allows to use the *nix end of line character (“\n”) in your text editor before saving a script you have modified”

    Thanks,
    Dan

  • Tak

    Thanks for the instructions. I’m running 10.6.8 and found that instruction (c) was slightly different as far as permissions go: “chmod o+w ~/Sites/phpmyadmin/config”

    As per documentation: http://localhost/~tak/phpmyadmin/Documentation.html#setup_script

    I had to add “chmod o+wr”

    Thank You,

    Tak

  • http://www.claimid.com/koolinus kOoLiNuS

    thanks for sharing!

  • Patcharapon CHAICHUANGCHOT

    thanks for sharing, good instruction :)

  • Everett Considine

    I’ve installed it but I’m unable to use “root” as the login with the password I created. When I log in with those values in the command line mysql it works. What do you think I’m doing wrong?

    • Anonymous

      Check the password value in config.inc.php which should be in the root level of the phpmyadmin folder:

      “$cfg['Servers'][$i]['password'] = ‘passwordhere’;”

  • Awa4000

    Dude, you rock.

  • Awa4000

    For those who get the #2002 error you can just replace “localhost” with “127.0.0.1″ and walla.

  • http://www.briansutton.net docB

    Just like a lot of other people, I have struggled with the issues that are beautifully resolved here. Well done Neil, you coolest guy. Thank you for this.

    Brian

  • Moltar

    Really appreciated this article along with the one on installing/configuring AMP on 10.7! You’re what I would imagine myself to be like if I had skills. Kudos to you, sir, as you are indeed the coolest guy on the planet. :-)

  • Alex

    Finally I found the answer… thanks!

  • http://twitter.com/abuhawa Abu Hawa

    Any idea how I wan to avoid external user (internet) from from accessing the phpmyadmin page as the phpmyadmin folder is residing in the Site folder?

  • Schaerli

    nice, thx

  • Pingback: New Mac installation | Samuel Wong

  • http://coolestguyplanettech.com Neil Gee

    yes but make sure the config file is stored in the directory above

  • Trista Woods

    I am having an issue on 10.7. When I enter 
    http://localhost/~username/phpmyadmin/setup/
    in my browser (and yes I do change ~username to my username) I get the 404 not found error. Any suggestions? 

    • http://coolestguyplanettech.com Neil Gee

      I would double check the path is correct and is visible in the finder
      - then also check Sys Prefs > Sharing > Web Sharing – do you have a green enabled button? can you see your personal website folder?

  • http://coolestguyplanettech.com Neil Gee

    cool – yes there are 2 document web sharing roots – one in the User/Sites/ and one in the Library/WebServer/Documents

  • Paul

    Does anyone have any idea how to resolve this issue on a Mac?

    This is the message I get when I try to login to phpmyadmin…#1045 Cannot log in to the MySQL server and

    The mcrypt extension is missing. Please check your PHP configuration.

    Thanks in advance for any help at all!

  • Squidz

    Thanks for the great post… I had gone through a MAMP set up from another site, which worked great. But I have struggled getting phpMyAdmin working. 

    You steps were so straightforward I was hoping to get it done finally. 

    However, when I go to http://localhost/~myusername/phpmyadmin/setup I get a directory index list of the files rather than a set up screen.

    Can anyone help resolve this? If I click on the “index.php” or “config.php” that I see in the directory, the browser presents the file’s code.

    I’m stumped.

    • Joe

      i have the same problem here.. have u got it fixed? thanks

  • Pingback: MySQL « Foo, Bared.

  • http://www.myfreeipadstory.com JG

    All good for me. Thanks.

  • Dennis

    Can phpMyAdmin be installed on Mac OS X Lion Server?

    • http://coolestguyplanettech.com Neil Gee

      absolutely

      • Dennis

        The installation went fine as far as I could tell. But, when I try to login on the phpMyAdmin login page, I get the “#2002 Cannot log in to the MySQL server” error. I assume that this is referring to the “mysql 2002 socket error” described in the initial installation step. I entered the two “sudo” lines described initially. How would I know if they were actually successful while in Terminal?

        • http://coolestguyplanettech.com Neil Gee

          what do you see in /var/mysql …
          cd /var/mysql
          ls -la

          • Dennis

            Thanks so much for the quick responses! I’m a real novice with Terminal. So, I may not understand.

            When I type cd /var/myql, I don’t think I get “anything”. Here’s a copy of the lines:

            3c07545a9b6e:~ dennisfennell$ cd /var/mysql
            3c07545a9b6e:mysql dennisfennell$

            Should I be entering a new command on that second line to see what’s under the mysql directory?

          • http://coolestguyplanettech.com Neil Gee

            yes use

            ls -la

            and tell what the output is

          • Dennis

            Before when I typed it, I used a capital “i” instead of a lower case “L”. This is what I got:

            3c07545a9b6e:mysql dennisfennell$ ls -la
            total 8
            drwxr-xr-x   3 root  wheel   102 Jan 17 20:29 .
            drwxr-xr-x  37 root  wheel  1258 Jan 17 20:28 ..
            lrwxr-xr-x   1 root  wheel    14 Jan 17 20:29 mysql.sock -> /tmp/mysql.soc

          • http://coolestguyplanettech.com Neil Gee

            you are missing a ‘k’ on the end – should be /tmp/mysql.sock , run the command again…

            sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

          • Dennis

            I entered the command above, the output was:

            ln: /var/mysql/mysql.sock: File exists

          • http://coolestguyplanettech.com Neil Gee

            is mysql running?….. try

            sudo /usr/local/mysql/support-files/mysql.server start

          • Dennis

            In my System Preferences is a MySQL icon which when opened says MySQL is running.

            I did run the sudo above. I got “Starting MySQL
            SUCCESS!”

            However, when I try to login, I get the 2002 error again.

          • http://coolestguyplanettech.com Neil Gee

            Instead of localhost try 127.0.0.1 in the url string

  • http://coolestguyplanettech.com Neil Gee

    Ok change the string back to localhost

    Then in the terminal delete the previous alias and recreate:

    sudo rm /var/mysql/mysql*

    then recreate:

    sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

    • Dennis

      Thanks for sticking with me.

      I think I did the two steps correctly. There were no error messages. However, when I tried to log in, I got the “#1045 Cannot log in to the MySQL server error” again.

      • http://coolestguyplanettech.com Neil Gee

        ok well that will mean that the the password is incorrect

  • http://coolestguyplanettech.com Neil Gee

    no that is the password but perhaps it is wrong – it has to be the password for the mysql user – can you log into mysql via Terminal

    mysql -u username -ppassword

    (no space between -p and password)

    • Dennis

      This is what I entered and the output:
      3c07545a9b6e:~ dennisfennell$ mysql -u dennisfennell -pluty$15
      ERROR 1045 (28000): Access denied for user ‘dennisfennell’@'localhost’ (using password: YES)
      3c07545a9b6e:~ dennisfennell$

      • http://coolestguyplanettech.com Neil Gee

        You see you cannot log in as the username /password are incorrect for mysql

  • DougTred

    Well That was easy enough. FAB step by step guideguide

  • Xutip

    Thanks so much for this, was a great help!

  • Jeffrey Mason

    Hi,

    I’ve gone through the steps, double and now triple checked everything, but I still must be missing something.

    I am getting the #2002 Cannot log in to the MySQL server error.

    Can someone help me through it?  I’m sure it’s something simple.  This is the 2nd time for this install, 1st went well and phpmyadmin worked, but I remember having a bit of trouble.

    Any support will be greatly appreciated.

    Jeff

  • Pineapplehead88

    Thank you, great tutorial! I only had one issue after following the steps above – I had set a password in the phpmyadmin config file for root, but somewhat carelessly hadn’t done so in mysql.

    I did this in terminal:

    $mysqladmin -u root password

    then set the root password The error I kept getting was #1045. After setting the root password in mysql to the same as the one I had set in phpmyadmin everything worked.Thanks again, I had been struggling with this for a while and your tutorial really helped. 

  • Mark D

    Thanks, great tutorial.  I was struggling with this before I found your guide.  I followed it to the letter and it worked perfectly.  

  • Pingback: Setting Up A PHP/MySQL Web Server On A Mac | Montana Flynn

  • Venkatesh Budi

    great tutorial. thanks a lot for writing this tutorial.

  • Evan

    Open the config.inc.php file and change $cfg['Servers'][$i]['host'] = ‘localhost’; to $cfg['Servers'][$i]['host'] = ’127.0.0.1′;

  • http://www.facebook.com/Jessy.SC.Li Jessy Dou Li

    thanks for this detail instruction for setting up everything.

  • Mitashade

    Amazing guide(s). Total newbie to MySQL and PHP, trying to make a simple database site to track player information, this is an amazingly helpful first step. <3

  • atreynolds

    I’ve followed everything however I get an error when I log in:  Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly.  Any suggestions?

  • gratefulnoob

    Thank you so much for this tut.  Worked perfect!

  • Jr

    Thank you very much my friend for this tut, it worked really well! keep up the good work!

  • Pingback: MacMini server deel 14: Wordpress « AJvK.nl

  • Pingback: Bit-taming » PHP Basic Authentication template

  • Pingback: Installing phpMyAdmin on Mac OSX 10.8 Mountain Lion & 10.7, 10.6 « fly2universe's Weblog

  • Pingback: Baker Street Systems

  • Pingback: OS 10.9