12 February 2013

Installing phpMyAdmin and removing the popup authentication in CentOS 6

Installing phpMyAdmin is a snip in CentOS, but there is a little trick that most tutorials skip out. For some reason the default setup (using standard repositories) does not like you having a null password for your mySQL root account. I know that you are supposed to be able to set a blank password in the pma config file and set the option to allow blank passwords to true, but this did not work for me until I set a root password. I kept getting a popup box that looked exactly like a .htaccess Apache protect but was actually just a Javascript prompt.
So here goes:

Step One - enable your EPEL repo:

 $ cd /tmp  
 $ wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm  
 # rpm -ivh epel-release-6-5.noarch.rpm  

Step Two - Install phpMyAdmin

 # yum search phpmyadmin  
 # yum -y install phpmyadmin  

Step Three - optionally edit your Apache conf

If you get Apache forbidden errors (should not be the case) you can try editing your .conf file
 # vi /etc/httpd/conf.d/phpMyAdmin.conf  

So that it looks like this:

 <Directory /usr/share/phpMyAdmin/>  
   Order Allow,Deny  
   Allow from All  

Remember to restart Apache afterwards

Step Four - Set a mySQL root password

 $ mysqladmin -u root password "hackme"  

Step Five - Edit your config.inc.php file

You should be able to navigate to http://localhost/phpmyadmin/setup and use that to create your config file, but I rather copied the sample to a new file.

Your /usr/share/phpMyAdmin/config.inc.php file should include the following:

 /* Authentication type */  
 $cfg['Servers'][$i]['auth_type'] = 'config';  
 $cfg['Servers'][$i]['user'] = 'root';  
 $cfg['Servers'][$i]['password'] = 'hackme';  
 $cfg['Servers'][$i]['AllowRoot'] = true;