Archive for the ‘DBA’ Category

Unable to start Cluster Service on One Node

A Windows Failover Cluster demo I gave a work failed horribly when the same demo the previous week went perfectly. A case of

Backing up the structure of MySQL databases

Today I wanted a quick and easy way to generate a backup of the structure of all MySQL databases in one easy hit. Here’s a couple of ways you can do this with the tools you’re likely to find everywhere. Firstly, we can use the following query to generate a list of mysqldump commands. The [...]

Powershell for Failover Clustering

As it’s looking increasingly likely I’ll be deploying Windows Failover Clustering, as a HA solution at work, I thought it would be prudent to swot up on a little related Powershell. I’ve picked out a few clustering cmdlets that will be helpful for building scripts to manage and monitor a cluster. First things first! If [...]

Add column headers to a MySQL Outfile

Unfortunately the MySQL SELECT INTO OUTFILE command doesn’t support an option to output the headers of the result set you are exporting. A feature request has been open for over 2 years to sort this with no apparent activity. A few people have had the idea of using a UNION ALL to include the headers [...]

Schedule a Windows server reboot

Just a quick one today as I’m always forgetting how to do this! I occasionally have to schedule server reboots to happen in the middle of the night. This is easily achieved by using the AT command in a command prompt window. The following example will schedule a server reboot for 3AM as a one-off [...]

Why didn’t I know this SSMS Shortcut?

I was in two minds about whether to blog about this as I’m sure many people know this already! What the hell! I’m not embarrassed to admit I don’t know everything. Even the most casual user of SSMS knows that you can drag any database, table or column from the object explorer to the editor. [...]

Gathering SQL Server Data Cache Information: Part 2

In a previous post I showed how you can collect information on what is held in the data cache. The data collected here was just a simple summary of how much space each database was consuming. While useful we will need more detailed information on what is inside the cache to get a proper handle [...]

Gathering SQL Server Data Cache Information

I’m currently building a CMDB at work and I wanted to include a bit of performance data in the information collected. The data cache is probably the biggest consumer of memory within SQL Server so It makes sense to collect this for future analysis. As a start I’m gathering the amount of space each database [...]

Using sp_rename with schemas

I’ve noticed people before struggling using sp_rename with tables that aren’t in the default schema. Many people don’t use schemas, so there’s often confusion, when they finally do come across the need to rename a table belonging to another schema. Assuming the below ‘Suppliers’ table is in the users default schema (usually dbo) then the [...]

Parse MySQL Slow Logs with mysqlsla

Here’s a bash script that you can use to parse multiple MySQL Slow Query Log files, in one sweep, into something much more understandable. The script uses the handy utility mysqlsla so make sure this is in your path.  mysqlsla parses, filters, analyzes and sorts MySQL slow, general, binary and microslow patched logs in order [...]