phpMyAdmin for MySQL
29 December, 2008 | Filed under “Apache on the Macintosh”
Note: Building on the earlier articles Apache on the Macintosh, PHP for Apache, and MySQL and the Macintosh, this article focuses on the installation of phpMyAdmin on the same client Macintosh running Mac OS X as discussed earlier. The phpMyAdmin project is more than ten years old and presently at version 3.1.1. For compatibility, you will need at least PHP 5.2 and MySQL 5.
What is this MySQL, anyway?
With MySQL up and running on your local machine, the obvious question is how to create, gain access to, and maintain a MySQL database. MySQL is an implementation of Structured Query Language (SQL), originally developed by IBM and later standardized. SQL is, in short, a language for relational databases. So, do I need to know and use SQL commands to administer this thing? As it happens, no. This is where phpMyAdmin takes on the role of go-between, or negotiator, if you will. Itself a PHP script running in your web browser, it adds a human interface to it all.
Acknowledgement
I claim no intimate knowledge of phpMyAdmin configurations. Everything below this paragraph is the direct result of me consulting the documentation that comes with the script and recommendations of people who know their stuff. For the most part I will parrot back information already available – much like talking aloud to myself while struggling with the ins and outs of databases in an ExpressionEngine content management system. In other words, necessity is not the mother of invention in this case. I simply need to make sure that I have something to refer back to should web pages on e.g. Train Signal and Server Codex go the way of the dinosaur. In the case of Server Codex there are indications that this is already the case. They do, however, note that theirs is a live document “that will be constantly refined”. Now, that is more than this dinosaur can promise.
Let’s get on with it
1. Head over to the official phpMyAdmin website and download the latest stable release. I opted for the ZIP archive. Depending on your choice, the compressed, downloaded file may or may not decompress automatically. At Versiontracker you should be able to find a decompression tool. Once decompressed, you have a folder named phpMyAdmin-3.1.1-all-languages (or similar) on your hands.
2. Change the name of the folder to whatever makes sense to you. For practical and logical reasons, however, a good suggestion is:
phpMyAdmin
3. Move (or copy) the folder thus:
X > Library > WebServer > Documents > phpMyAdmin
where X represents the name of your main hard disk/partition. If you copied the folder, the original is no longer needed and can be trashed.
Note: Remember from the first article in this series that you, as I, are stubbornly working with virtual hosts on a non-default, dedicated partition. Apple’s pre-installed Sites folder (as one of two suggestions by Server Codex) is therefore not the logical place for phpMyAdmin.
Configuration
Whenever phpMyAdmin is started, it first loads the file config.default.php from its libraries folder and then overrides those values with anything found in a user specific file called config.inc.php. And where is this config.inc.php file? Well, up front it is nowhere, so you will have to create your own or, rather, modify a sample document.
Note: If the default value is okay for a particular setting, there is no need to include it in config.inc.php.
4. Open the sample document:
X > Library > WebServer > Documents > phpMyAdmin > config.sample.inc.php
5. You will modify this document, but before doing so, save it to the same directory with the new name:
config.inc.php
This ensures that you do not accidentally overwrite anything in the original sample document.
6. There are several ways to configure the login behaviour of phpMyAdmin. If you go with the (maybe) obvious “cookie method”, do as instructed in the documentation that comes with the script:
X > Library > WebServer > Documents > phpMyAdmin > Documentation.html
If you want to avoid the problems described below in the mcrypt chapter, opt for, e.g., an HTTP authentication. Depending on your database needs, uncomment or add parameters based on availability as per the Configuration section in Documentation.html. Instead of going through the sample document line for line, adding and/or deleting, I simply state: Here is what works for me as of this writing:
<?php
// Bjorn 081228 (Refer to 'config.sample.inc.php' for comments)
// Original document Western (Mac OS Roman) changed to Unicode (UTF-8, no BOM)
$i = 0;
$i++;
$cfg['Servers'][$i]['auth_type'] = 'http';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Servers'][$i]['socket'] = '/tmp/mysql.sock';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
$cfg['Servers'][$i]['relation'] = 'pma_relation';
$cfg['Servers'][$i]['table_info'] = 'pma_table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma_column_info';
$cfg['Servers'][$i]['history'] = 'pma_history';
$cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
?>Important: I made one significant change to avoid the Error #2002 described later:
$cfg['Servers'][$i]['connect_type'] = 'tcp';
was changed to:
$cfg['Servers'][$i]['connect_type'] = 'socket';
and the following line was added:
$cfg['Servers'][$i]['socket'] = '/tmp/mysql.sock';
This points the phpMyAdmin configuration to where MySQL stores its socket file.
7. Save the document and close it.
Does it work?
The time has come to test if your local installation of phpMyAdmin works.
8. Point your browser to:
http://localhost/phpmyadmin/
or simply:
localhost/phpmyadmin
Note: If you renamed your phpMyAdmin folder to something different from phpMyAdmin, the address should reflect this.
Depending on your configuration, whenever you are prompted for a user name and a password, it would be root and your_MySQL_password, respectively.
For the record: I still have (at least) one configuration problem to sort out on my own system. When I log in, I get the message: “Your PHP MySQL library version 5.0.45 differs from your MySQL server version 5.1.30. This may cause unpredictable behavior”. I live in the hope of returning with an update sometime in the future.
mcrypt
If you get the following warning on login:

my guess is that you went with the cookie login alternative which may choke for at least two reasons. Either you are using the default Mac OS X PHP installation (read up on this in the second article of this series) – and the mcrypt extension is not part of that installation – or you are on a 64-bit computer, or both. This is a major headache because it is (probably) not possible to install mcrypt without compiling the whole thing from source – something I am not willing to do as mine is not a production environment.
Quoting the phpMyAdmin documentation: “When using the ‘cookie’ authentication method, the mcrypt extension is strongly suggested for most users and is required for 64–bit machines. Not using mcrypt will cause phpMyAdmin to load pages significantly slower.”
If you still want to login with cookies enabled, you are on your own. But as always: Suggestions and solutions are appreciated!
FAQ the problems
If phpMyAdmin returns error messages or if you have questions in general, consult the Documentation.html installed together with everything else in your phpMyAdmin folder. The section on Frequently Asked Questions may have the answers.
If you get the following error message on login:

a possible solution has already been mentioned. Otherwise you will eventually have to sort it out yourself because your configuration may differ from mine, and the scenario is complex. This MySQL forum entry may come to your rescue.