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 in the same directory where examples, js, libraries, setup and themes directories are. Paste the following into that file:

$cfg['blowfish_secret'] = 'some_string';  // use here a value of your choice
$i = 0;
/* First server */
/* 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.

23 thoughts on “phpMyAdmin on Windows Azure Web Sites”

  1. 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.



  2. 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.

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

  4. 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



  5. 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?

  6. 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.

  7. 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!

  8. 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.

  9. 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.

  10. Hi

    This is really good news. I followed the steps but I get a 500 Server error.
    So, I went back through the steps again, found that I had done it all correct.

    500 error persists.
    Any clues for me?

  11. I think figured out what was wrong:
    just made two changes and now all working:
    removed comments like
    // Replace with value from connection string
    and made blowfish_secret shorter

  12. Hi I have the same problem , do not give me any error alone page remains blank , if someone help me please .

    Greetings and thanks for your attention.

  13. I am getting error: cannot login to mysql server. while i give correct username or password.

    Any help would be appreciated.

  14. Hi,
    I have already followed all the steps, but i still can not logon phpMyAdmin page. The error i get is #1045 Cannot log in to the MySQL server.

    May i know if there is anything to do with $cfg[‘blowfish_secret’] ?

  15. Bro you save me some time and some nerves – I am so glad I found you article. Had to migrate a WordPress Site for my client – try to do it through workbench it kept giving me trouble. Always have done it manually (request will time out 9-10) rather than plugins such as Duplicator. Just want to say huge thanks to you man!

  16. I am getting #2002 Cannot log in to the MySQL server Error. 🙁 Please help.

    And also am not able to do 2nd step i.e “Link the site with a MySql database” ?

    Please help me or provide a video session of this tutorial !!

  17. Where is the exact location for filling the ‘host’ parameter? I’m not able to find the exact file…
    I’m using Microsoft Azure with WordPress and MySQL database. I followed all the explained steps on this helpful article, but from the phpmyadmin screen I got 2002 error

Leave a Reply

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