phpMyAdmin on Windows Azure Web Sites

In my previous post about the migration of a WordPress site to Windows Azure I mentioned that I used phpMyAdmin to import existing blog data into a MySql/ClearDb database in Windows Azure. phpMyAdmin is a web based tool for administering MySql databases. It can be used to create tables, edit the data in tables, export/import/backup data and many other tasks. I found it to be an adequate tool for all MySql db administration needs in Windows Azure. This post describes how to install and configure phpMyAdmin on Windows Azure Web Sites.

1. Create an empty site

First you’ll need to create a new site in Windows Azure. 10 free sites are allowed per subscription and phpMyAdmin will work fine on a free site. Create an empty site using “Quick Create” option in Windows Azure Portal:

2. Link the site with a MySql database

If you already have a MySql database or need to create one then use the Linked Resources page to link that database with your site.

Once the database is linked get the connection string by using the “View conneciton strings” link on the site’s dashboard page:

You will need the information from this connection string to logon to the database via phpMyAdmin. It will looks similar to this:

Database=some-db-name;Data Source=some-hostname;User Id=some-username;Password=some-password

3. Download and configure phpMyAdmin

Get the latest version of phpMyAdmin from the offical site. Extract it to some temporary location on your hard drive. Create a new file with name config.inc.php in the same directory where examples, js, libraries, setup and themes directories are. Paste the following into that file:

<?php
$cfg['blowfish_secret'] = 'ba17c1ec07d65003';  // use here a value of your choice
$i = 0;
/* First server */
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'some-hostname';  // Replace with value from connection string
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
?>

5. Upload phpMyAdmin files to Windows Azure

Multiple upload methods are supported. I used FTP with FileZilla. FTP hostname and username can be obtained from the site’s dashboard page in management portal. Once you connected via FTP, upload all the files into the /site/wwwroot/ directory.

6. Logon to MySql database

Browse to the newly created site. You should see the phpMyAdmin logon page:

Use the User Id and Password from the connection string to logon.

28,836 views

ruslany on December 17th 2012 in PHP, WAWS

PoorFairAverageGoodExcellent (5 votes, average: 5.00 out of 5)

13 Responses to “phpMyAdmin on Windows Azure Web Sites”

  1. Gravatar ImageTom responded on 23 Dec 2012 at 3:26 am #

    Hi,

    This is a good article, my only thought is that there is no word on security. If you use PhpMyAdmin it is a good idea to use SSL while on the site, so your database credentials are never sent in the clear.

    Regards,

    Tom.

  2. Gravatar ImageFred responded on 20 Jan 2013 at 9:03 am #

    So do you need a PhpMyAdmin “web site” for every database? Or can you link all databases to PhpMyAdmin?

  3. Gravatar Imageruslany responded on 21 Jan 2013 at 9:58 am #

    Fred, in my tests, as long as the database server was the same, I was able to connect to different databases by using a single PhpMyAdmin site. When I used the username/password for a particular database, only that database was available in the phpMyAdmin.

  4. Gravatar ImageHashid Hameed responded on 30 Mar 2013 at 2:55 am #

    I am getting #2002 Cannot log in to the MySQL server Error. :-( Please help.

  5. Gravatar ImageJim responded on 11 Apr 2013 at 1:49 pm #

    Fantastic article, thanks. @Hashid – It sounds like you haven’t set the host correctly in the config.inc.php file.

  6. Gravatar ImageLasse Laursen responded on 08 May 2013 at 6:36 am #

    Hi I also get the #2002 error when trying to login. The hostname, how much of the connection string shall be used?

    Please do revert, as I need a fix for this.

    Thanks in advance

    Br

    Lasse

  7. Gravatar ImageSteve responded on 09 May 2013 at 7:45 am #

    Great post and easy even for a beginner to follow. Everything worked as described. Thanks!
    Now comes the issue of trying to import the mysql DB when it’s bigger than 2.048MB. I’ve tried creating and inserting the .htaccess file as described in many posts but it didn’t seem to work. And there’s no way to access the php.ini file that I’m aware of. It’s frustrating because the DB is only 6MB and I’m looking at having to rebuild my wordpress site by hand. Has anyone else had luck beating the 2MB limit?

  8. Gravatar ImageJason responded on 10 May 2013 at 6:11 am #

    I am also unable to get this to work. It states teh same error the person above has…#2002 Cannot log in to the MySQL server Error

    the settings are correct.

    Is it a must that you create a dedicated site for this? and upload into the root of that site? I didn’t do that. i had a site… created a folder and used that as the phpmyadmin directory.

    also… you have not stated what version that you were using of phpmyadmin, as the settings file in the latest version is different a bit.

    please advise.

  9. Gravatar ImageJason responded on 10 May 2013 at 6:18 am #

    Please disregard my previous post. It seems that you must not allow the phpmyadmin to use its own internal setup system in the setup folder.

    I believe that it didn’t work as the cookie secret was not in that file it created.

    Perhaps it would work if I had everything correct.

    I went back into your tutorial… followed it to a T and blamo – working phpmyadmin on azure!! hooray!

  10. Gravatar ImageDevon Sutton responded on 01 Jul 2013 at 8:09 pm #

    There is a simpler approach; to summarise before going into the details: You can access your remote azure MySQL database from your local phpmyadmin and use the import, export – all the functions you’re used to using on phpmyadmin.

  11. Gravatar ImageMonica responded on 28 Aug 2013 at 2:40 am #

    I’m getting the #2002 error both when I try to access phpmyadmin from the new website I created in azure with the helpt of this tutorial, and when I try to connect to it remotely from the phpmyadmin I have running on my localhost.

    Has anyone had any luck with this? I have no idea what I can do about that error and googling it doesn’t seem to help either. Any help would be appreciated! Thanks in advance.

  12. Gravatar Imagetoshi responded on 02 Jan 2014 at 9:31 pm #

    thank you! how can i be a super user?

  13. Gravatar Imageztv responded on 20 Jun 2014 at 5:56 am #

    Connection string from the database of from the website section?

Trackback URI | Comments RSS

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

XML Markup: If You want to add XML code to the comment please XML encode it first, otherwise the code will not show up.

Recently Published Articles