phpMyAdmin your way into OpenShift Express database management bliss

The latest OpenShift Express release really makes it easy for developers to manage their MySQL databases.  With the addition of phpMyAdmin, any application type (JBoss, Ruby, Python, PHP, Perl) can easily administer MySQL.  That’s right – ANY application type – you don’t need to create PHP applications in order to use the phpMyAdmin support.  To show you how freakin cool this is, I’m going to deploy Redmine (a RoR developed application for project management and then use the phpMyAdmin interface to do cool things like browse, export, import, and modify rows in the database.

If you’re following along at home, I’m going to use the github quickstart repository to deploy the initial Redmine application and database before switching over to phpMyAdmin.

Step 1: Create a new OpenShift

rack-1.1 application
rhc app create redmine ruby-1.8
 

Step 2:Add MySQL support to the new application – make a note of the admin password and connection URL – we’ll use them in Step 4

rhc cartridge add mysql-5.1 -a redmine

Step 3:Add the Redmine github repository to your new OpenShift application

cd redmine
rm -rf *
git remote add upstream -m master git://github.com/openshift/redmine-openshift-quickstart.git
git pull -s recursive -X theirs upstream master

Step 4: Update config/database.yml with the correct database information for ‘production’.  In my case the ‘production’ section changes from:

production:
  adapter: mysql
  database: redmine
  host: Database host provided by openshift
  username: admin
  password: password provided by openshift
  encoding: utf8

to:

production:
  adapter: mysql
  database: redmine
  host: 127.1.6.129
  username: admin
  password: 3UxHRUL1lR9d
  encoding: utf8

Step 5: Commit and push!

git commit -a -m "update database connection information"
git push

At this point you should be able to visit http://redmine-[yourdomain].rhcloud.com.  Try it out by logging in as admin/admin and create a new project.

When you’re ready, come back to get it on with phpMyAdmin.

Deploying phpMyAdmin on top of a running Express application is so simple my mom could do it!  Using a similar command line to how we add support for MySQL, we’ll run:

rhc cartridge add phpmyadmin-3.4 -a redmine

Once this is finished, you can go back to your browser and access https://redmine-[yourdomain].rhcloud.com/phpmyadmin/

Woah, slow down David, this is asking me for a password!  Yep, we don’t want to make database administration unsecure (also note how I’m using https)!  The username here is ‘admin’ and the password is the mysql password you added to config/database.yml.

You should now see the [maybe] familiar phpMyAdmin interface.  You can select the ‘redmine’ database from the database browser on the left.  Let’s do that and then find the ‘projects’ table.  From this interface, we could go in and edit individual fields for the test project we created.

Being able to edit fields in the database probably isn’t that important since your application most likely has a user interface for supporting this kind of thing.

However, your application probably doesn’t have the ability to easily import and export database dumps.  Using the features built in to phpMyAdmin you can manage the lifecycle of your applications backend datastore without the hastle of googling for MySQL command line help!

The other great thing about this support is that you can migrate from one OpenShift Express application to another – making it easy to have a dev environment and a production environment all hosted in the cloud!

Thanks for tuning in!

- Your friendly neighborhood PaaS Evanglist – aka http://twitter.com/#!/dblado

 

Hi David.

I followed your steps in this article, but apparently the application does not start on OpenShift.
There's no error messages when execute git push.
Do you have any suggestions? How do I get log messages from server?

Thanks.

I followed the above instruction and successfully installed mysql and phpmyadmin but when i tries to login phpmyadmin with the passwrod mentioned in database.yml file it does not accepts the password and prompts me again. my application is at http://geodine-sushilkumar.rhcloud.com

Hi @0120sushil;

How did you embed the phpmyadmin cartridge?  It should have printed the admin password to your console.  For example, if I use the rhc client tools, I get:  
rhc cartridge add phpmyadmin-3.4 -a django
Password: ********


RESULT:

phpMyAdmin 3.4 added.  Please make note of these MySQL credentials again:

   Root User: admin
   Root Password: 47rW-xxxxx

URL: https://django-xxxxx.rhcloud.com/phpmyadmin/

Hope that helps;
~Nam

More from this author