Deleting a classic ClearDB MySQL database in Azure

Websites in Azure that require MySQL will be default provision them in an external service provider known as ClearDB.

This is slightly frustrating and surprising, given that MySQL can be run in Azure itself. I won’t go into how to do that as there are already a number of existing articles covering that topic.

What I could not find however was a clear and simple way to delete an existing MySQL database that was stored in ClearDB.

This is compounded further by the fact that if you created your web app using the classic Azure admin portal (ie. using manage.windowsazure.com instead of portal.azure.com) – the linked MySQL database won’t show up and therefore can’t be managed or upgraded.

The scenario is this: my TheCloudMouth.com blog site has been running for a number of years and the database had grown to capacity. Since I created it some time ago in the classic admin portal I had no way to upgrade the database as it wasn’t “connected” to my current Azure portal. I went around in loops between different processes and support cases, all to no avail. Long story short I had to create a new MySQL database in ClearDB (which I did this time through the modern Azure admin portal), migrate the database, modify the wp-config.php of my WordPress site to point to the new database, and away we went.

Unfortunately, I was still getting emails on a daily basis from ClearDB telling me that the original database was at capacity. Logging into the ClearDB portal I could not see any way to delete the database (literally, there is no delete button or any other management option).

Raising a case with ClearDB to delete the database was no help as they just kept pointing back to Microsoft as the billing source and said I had to delete it from there – which is not a possibility.

So I found a simple and quick workaround to delete the database.

What we know

When deleting a web app in the classic Azure admin portal gives you the option to delete the linked MySQL database:

If we expand the warning we see this:

What we need to do

Create a new web app with any free name:

Once it’s completed, browse to Linked Resources, then Link a resource:

Select Link an Existing Resource:

Then select MySQL Database:

Specify the database from the drop-down:

Accept the terms, press the big tick button, and linking should be completed within a few second. What you should see is something like this:

So now we can proceed with deleting the app and select the attached database:

Browsing back to your ClearDB account you should now see the “deleted” database, now with different information but most importantly a Delete button (NOTE: database in below screenshot is different from previous screenshots):

Hit that Delete button and you’re done, this whole frustrating experience with ClearDB is now behind you!

Hacking your way to root on FreeBSD in Azure

UPDATE 19/06/2016: Apparently the root user is disabled on Linux virtual machines in Azure, so the guidance is to use sudo to run commands with elevated privileges. So the below post is somewhat irrelevant, but if you still want to log in as the root  user then it’s still valid. Or you can obtain a root shell using “sudo -s”. Fore more information about the documented way to do this I have been directed to a couple of articles by Microsoft support: Introduction to Linux on Azure, and Using root privileges on Linux virtual machines in Azure. I wouldn’t have found them anyway because FreeBSD isn’t Linux. 🙂

 

Back in the early to mid 90’s before I discovered Windows NT and changed the focus of my career, I spent a lot of time playing around with FreeBSD, OpenBSD, Redhat, and even Solaris. Let’s just say that CLI was and still is my friend (I still run a Cisco 867 router at home).

As much as I love spinning up Windows servers and desktops in Azure for labs and tests, I’d never really had a reason to fire up a Linux or Unix server. That changed when my old favourite FreeBSD was launched on the Azure Marketplace.

So I spun up a FreeBSD instance using the low-cost A0 instance as I still didn’t know what I was going to do with the server (and it’s been about 15 years since I’ve used it – so my skills are a little rusty).

When provisioning the server, you’re asked to specify a username, but upon logging in to the server I found that I was just a mere mortal – incapable of switching to the root user:

Unfortunately, the documentation on working with FreeBSD in Azure is lacking. Looking at an old blog from 2014 about running FreeBSD in Azure it indicated that you could log into root with no password – which seemed highly unlikely for a terminal session across the Internet. I gave it a try anyway and got this:

What I did find was that apparently I could create a new user with sudo privileges from within the Azure portal:

Looking at the article about how to reset access in Linux virtual machines on Azure under the section Create a new sudo user account I wasn’t much more enlightened.

I thought I’d give it a crack anyway and created an account called sudouser with a new password. Lo and behold it worked!

My next step was to then make my original account a member of the “wheel” group:

Great, that’s done. Now let’s try to su to root again:

Oh that’s right, I don’t know the password for the root account.

Back to our sudo user to reset the password:

Ok, password is set, let’s try again:

Time to strap on my rollerblades and HACK THE PLANET!!!

 

 

P.S. It’s quite possible that my original account could have executed the sudo commands as necessary, but I didn’t test it while figuring this out – so I welcome anyone to test it themselves and give me some feedback.