I have been recently working on a PHP tutorial from Lynda.com and I ran in to some trouble with it. The class that I am doing is from 2007 and I have had to install some programs, Apache, PHP, MySQL and phpMyAdmin in order to be able to go along with these classes. All of this stuff is a bit new to me to work with considering the sites that I have designed.
The class walks you through the instillation of each of these programs but they are a bit out dated. The one in particular that I had the most trouble with was phpMyAdmin so I am giving you the steps to handle this the way that I did in order to make this work for you. I did Google these but it was more for experienced programmers and web designers.
When I installed phpMyAdmin I got a #2002 error that had mentioned that my socket was not set up correctly or something like that. I some how managed to get it to work. These instructions are for the installation of phpMyAdmin version 3.2.2.1 which is the latest and this is being done on a Mac OS 10.5.8:
- Download and unzip phpMyAdmin from the site phpMyAdmin.net. Have it download to the desktop.
- Once it is unzipped, change the name to phpmyadmin.
- Open up the finder and place the folder as follows: your home file=>sites. It needs to be in sites because this is where the local server is.
- Open up phpMyAdmin and in the first set of php docs you will see config.sample.inc.php, you will want to open that up in your text editor program, text wrangler, dreamweaver or what ever program you can use to edit php style text. (Do not use Word or any other word processing programs)
- Now Save As that file to config.inc.php and make sure you save it in the phpMyAdmin file.
- What you are going to be doing here is adding some code in to this file config.inc.php that will give you your login access. If you where to try to go in and open phpMyAdmin on the local host you will more then likely have gotten this #2002 error which is why you are here. I am going to make this as simple as possible to do you bear with me. Here is what you are going to see in the first half or so of the code:<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* phpMyAdmin sample configuration, you can use it as base for
* manual configuration. For easier setup you can use setup/
*
* All directives are explained in Documentation.html and on phpMyAdmin
* wiki <http://wiki.phpmyadmin.net>.
*
* @version $Id: config.sample.inc.php 12304 2009-03-24 12:56:58Z nijel $
* @package phpMyAdmin
*/
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = ”; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
/*
* Servers configuration
*/
$i = 0;
/*
* First server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = ‘cookie’;
/* Server parameters */
$cfg['Servers'][$i]['host'] = ‘localhost’;
$cfg['Servers'][$i]['connect_type'] = ‘tcp’;
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = ‘mysql’;
- From here you are going to be adding in your user name and password $cfg commands so here is what you do: I have highlighted this one section for you: $cfg['Servers'][$i]['auth_type'] = ‘cookie’;
/* Server parameters */ $cfg['Servers'][$i]['host'] = ‘localhost’;
$cfg['Servers'][$i]['connect_type'] = ‘tcp’;
$cfg['Servers'][$i]['compress'] = false; -Right between that ugly green type you are going to add the following code, please note that you can change this: $cfg['Servers'][$i]['user'] = ‘root’; //unless you know that this is different, then to not change this!!!//
$cfg['Servers'][$i]['password'] = ‘cbb74bc’; // type between ‘ ‘ and you can change your password//
$cfg['Servers'][$i]['auth_type'] = ‘config’;
- With that done it should look something like the following with the password changed; /* Authentication type */
$cfg['Servers'][$i]['auth_type'] = ‘cookie’;
/* Server parameters */
$cfg['Servers'][$i]['host'] = ‘localhost’;
$cfg['Servers'][$i]['user'] = ‘root’;
$cfg['Servers'][$i]['password'] = ’123456′; // make sure you change your password//
$cfg['Servers'][$i]['auth_type'] = ‘config’;
$cfg['Servers'][$i]['connect_type'] = ‘tcp’;
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = ‘mysql’; -The bold section is what you just changed. Make sure you saved this. What is going to happen now is when you load phpMyAdmin, these configurations that you just did will now allow you to access this program via your web browser. It is more then likely that you will need to do 1 more thing here.
Now that you have done this, it is more then likely that you are going to get the #2002 Error again but this time the logging screen will not be there. Sorry, no screen shot on this one!! Here is what you are going to have to do now:
- Go to Applications=>Utilities=>Terminal and open up terminal
- You are now going to be configuring your computer to accept phpMyAdmin and this will be very easy and fast.
- With the terminal open you should have your username showing with a ~ in front of it like ~username. What you are going to do is either type in or cut and paste in the following command: sudo mkdir /var/mysql (then hit return) If you type this in please make sure that you pay attention to the spacing. You should have gotten a password prompt which you use your password that you have set up with the Mac.
- Next you are going to want to type or paste in the following: sudo ls -s /tmp/mysql.sock /var/mysql/mysql.sock (hit return) What you have basically done here is set up a directory in mysql and then linked in a file “mysql.sock” which from what I understand is the socket which correlates to the error you got when trying to get in to phpMyAdmin on your local host.
- Now go to you web browser and refresh the page.
If this is still not working there are several possibilities for this but I would suggest that you go back and redo my steps. Personally I did this about 5 times to make sure that it worked. There are other things to consider with this so I would suggest that if you went through my directions and it is still not working, let me know, these directions assume that you have done the instillation of the other programs I mentioned earlier.