Saturday, June 14, 2014

Manage MySql,PostgreSQL on the BlueMix

Actually BlueMix don;t provide the solution to operate   db like mysql,mongodb,PostgreSQL etc on the web UI.When people develop their application usually will create db or insert data for these open source db on the BlueMix.So we need a solution to manage these db on the BlueMix.I have already discussed about to maintain mongodb on the BlueMix in the previous post.Today I will talked about how to use manage mysql on the BlueMix.

Deploy phpMyAdmin on BlueMix

phpMyAdmin is a free software tool written in php, intended to handle the administration of MySQl over the Web. phpMyAdmin supports a wide range of operations on MySQL, MariaDB and Drizzle. Frequently used operations (managing databases, tables, columns, relations, indexes, users, permissions, etc) can be performed via the user interface, while you still have the ability to directly execute any SQL statement.

In the BlueMix category,we don;t have php runtime support that.So we will use php buildback to support that.I list the most import steps for you .

1.Since we need to use cf tool to deploy on the BlueMix,you need to download and install it from github.
https://github.com/cloudfoundry/cli

2.We use cf command or web console to create our mysql service.Before create the service,make sure you have use cf login -a api.ng.bluemix.net command to login into it.
create the MySQL service that the application will use. The command syntax is:

cf create-service SERVICE PLAN SERVICE_INSTANCE​

The service name is mysql, the plan is 100, and the service instance name is mysql_NMU. So you'll create your MySQL service like this:

cf create-service mysql 100 mysql_NMU

Here I create mysql service name is called mysql_NMU

3.The next step you need to download or clone the phpMyAdmin package from github from below address
https://github.com/dmikusa-pivotal/cf-ex-phpmyadmin
4.After you donwoload the installation package and open the htdocs\config.inc.php file.
Located the line 28,change 'cleardb-n/a' to 'mysql-5.5' .Below is the code after change.

/*
 * Read MySQL service properties from _ENV['VCAP_SERVICES']
 */
$services = json_decode($_ENV['VCAP_SERVICES'], true);
$service = $services['mysql-5.5'][0]; // pick the first service

4. Since we don;t want use the manifest.yml shipped in the default file,so we can use below command to push on the BlueMix.

cf push phpmyadminbluemix -b https://github.com/dmikusa-pivotal/cf-php-build-pack.git -m 128M --no-manifest --no-start

Bind previous created mysql service
cf bind-service phpmyadminbluemix  mysql_NMU

The we can start our application use below command

 cf start phpmyadminbluemix

5.After start the app,we need to use mysql credential to login into it.You can double click the application,click the runtime menu and find user name and password from Environment Variables.

6.Launch the url from the http://phpmyadminbluemix.mybluemix.net/,you can see below login screenshot.

7.Use the username and password provide by step5,you can login into it and maintain the mysql on the Cloud.


Deploy WebSQL on the BlueMix

WebSQL is the ultimate desktop replacement for managing your MySQL databases over the web. With interface that works just like your favourite desktop applications, you don't need to keep switching over webpages to get simple things done. Just login to your database and manage your database as if your are working on your desktop.It support MySQL, SQLite and PostgreSQL three dbs.

You can download the latest package from http://sourceforge.net/projects/mywebsql/files/stable/mywebsql-3.4.zip/download.

Deploy on the BlueMix for this php based application i same with phpMyAdmin.So I don't want to repeat the same steps here.But one place you might need to change on you side.Open the servers.php in the config foler.Change the code like below.If you want to manage PostgreSQL you can uncomment the line ,and comment mysql serice line for that.
/*
* Read MySQL service properties from _ENV['VCAP_SERVICES']
*/
$services = json_decode($_ENV['VCAP_SERVICES'], true);
$service = $services['mysql-5.5'][0]; // if you choose  the mysql service
       //$service = $services['postgresql-9.1'][0];//if use choose the postgresql-9.1
$host = $service['credentials']['hostname'];
$port=$service['credentials']['port'];

$SERVER_LIST = array(
'MySQL'           => array(
                            'host'     => $host. ':' . $port,
                            'driver'   => 'mysql5'
                        )
/* 'Localhost PostgreSQL'     => array(
                            'host'     =>$host. ':' . $port,
                            'driver'   => 'pgsql'
                       ),
*/
);

If your deployment on BlueMix is successful,you should see below screenshot.


So from below two apps deployment guide ,you can try similar solution with me to support other db on BlueMix.

17 comments:

  1. Thanks for the post. However when I run cf push I get a Server 500 error. I run OS X. Any ideas why this is happening?

    ReplyDelete
  2. This post helped me a lot. Thank you very much.

    ReplyDelete
  3. That is really amazing Information. It is very knowledgeable and so useful for me. Thanks for share.
    Koyna Sanctuary
    Mayani Bird Sanctuary Information

    ReplyDelete
  4. Thanks for providing this beautiful information and i will definitely comeback
    and see for more updates
    Digita marketing course in Delhi

    ReplyDelete
  5. Thank you so much for sharing your knowledge with everyone.
    mobile repairing course in delhi

    ReplyDelete
  6. We offer basic to advance level of mobile repairing, the technical training makes our smartphone repair course extraordinary, apart from that below are some top reasons to learn mobile repairing at AK info.

    Mobile Repairing Course in Delhi

    ReplyDelete
  7. We offer basic to advance level of mobile repairing, the technical training makes our smartphone repair course extraordinary, apart from that below are some top reasons to learn mobile repairing at AK info.

    Mobile Repairing Course in Delhi

    ReplyDelete
  8. Get in touch with the real estate agent. We at PROPERTY HUNTER shifted this service to a level much higher than the broker concept. Our highly trained and professional experts team will review and evaluate our client's needs and requirements.

    There are numerous factors affect the real estate market demand and supply, Interest rates, economic growth, de-mographics, mortgage availability and consumer confidence. For investors who have hold their properties for numerous years now can be a good time to sell and take advantage of new opportunities with aggressive payment plans whom has a great growth and return potential. We as expert in the local market will share with you the status of the real estate market and provide the proper advice to achieve your target. We have wide varieties of options of off plan pro-jects and ready residential and commercial properties. Ranging from Apartments; studios, pent-houses, townhouses, lands, plots, villas, office spaces, showrooms, hotel apartments and suits, commercial buildings, residential buildings, VIP towers and hotel projects. you can see more details like this article
    Property for sale Properties For Sale in Qatar

    ReplyDelete
  9. We are most reliable for DIGITAL MARKETING company in Delhi NCR, India. you can connect with us for online marketing, Advertisement, banners etc. We have experienced Employees that have good knowledge about online marketing in different types of social media handles.



    How you plan to sell our products through digital marketing







    Best online marketing company in Delhi NCR


    ReplyDelete
  10. I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.
    Best Mobile Repairing Course In Delhi
    Best Mobile Repairing Course In Laxmi Nagar Delhi

    ReplyDelete
  11. Nice article! I like the way of writing information. Internet for USA offers internet powered by internet Fiber. This is the organization and innovation behind our quickest private web plans. Check to see if Internet Services Providers in Houston.

    ReplyDelete