How-to: Setup MySQL and PHPMyAdmin on a VPS.

MYSQL and phpMyAdminMySQL is a powerful open source Relational Database used by many dynamic websites across the internet.

Originally developed in 1994 by Michael Widenius and David Axmark. MySQL was originally corporately sponsored under the name  MySQL AB. In 2008 MySQL AB was acquired by Sun Microsystems. In 2010, Oracle purchased Sun Microsystems. However MySQL is released under the GNU Public License therefore its continued support is still community based.

MySQL is commonly used as the database for most LAMP stacks or other AMP stacks. We have written a previous article on setting up a LAMP stack if you need to read up on that subject.

phpMyAdmin is a powerful PHP based gui for MySQL. phpMyAdmin was originally developed by Tobias Ratschiller, however has since gained more of a community support and it is used by developers everywhere.

Assuming you have already installed and configured Apache with PHP5 as your web server, this How-to will guide you through the remaining steps to install MySQL and phpMyAdmin.

Installing MySQL

First you need to install MySQL. On CentOS this couldn’t be easier just run the following:

 

yum install mysql-server

chkconfig mysqld on

/etc/init.d/mysqld start

 

Installing phpMyAdmin

Installing phpMyAdmin is almost as easy as installing MySQL, just a few more steps.

First you need to download and unzip the latest source from here. Once you download the files unzip in your servers web directory.

 

[root@cent5 html]# cd var/www/html/

[root@cent5 html]# wget http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/4.0.5/phpMyAdmin-4.0.5-all-languages.tar.gz

[root@cent5 html]# tar xvf phpMyAdmin-4.0.5-all-languages.tar.gz

 

This will create a directory called phpMyAdmin-4.0.5-all-languages in your web root. I would suggest you rename it something more easy to remember. Also to setup phpMyAdmin you will need to create a directory called config and make it writeable by the www user, in our case apache.

 

[root@cent5 html]# mv phpMyAdmin-4.0.5-all-languages phpMyAdmin

[root@cent5 www]# cd phpMyAdmin

[root@cent5 phpMyAdmin]# mkdir config

[root@cent5 phpMyAdmin]# chgrp apache config

[root@cent5 phpMyAdmin]# chmod 760 config

 

Next point your Browser to http://YourIPorHostName/phpMyAdmin/setup/

Select new server and enter your local MySQL server information, and click save. You should now be able to access your MySQL Database Server and create new databases, tables etc.

You should take additional steps to secure phpMyAdmin and do not leave this directory open to everyone. Use some form of secure authentication over SSL to accomplish this! Additionally you can block access to http via IPTables, and then access it my tunneling port 80 over an SSH session.

 

ssh -f ssh -f user@IPADDRESSOFSERVER -L 80:IPADDRESSOFSERVER:80 -N

 

 


Posted

in

, , ,

by

Tags:

Comments

2 responses to “How-to: Setup MySQL and PHPMyAdmin on a VPS.”

  1. Dennis Avatar

    Good article thanks for sharing.

  2. Pitechnologies Avatar

    Every beginner web developer should read the steps you have shared to setup MySQL and PHPMyAdmin on a VPS.

     

Leave a Reply

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