Mediatemple Grid Server (gs) MySQL and Support Problems

Let me be honest, I really REALLY want to like Mediatemple. Their website is extremely well designed, there’s loads of support information in their customer area, their GPU system gives you detailed information on high-resource scripts and files on your server and their file system has excellent uptime and good speeds.

Mediatemple GS Control Panel

However, as I write this one of our personal projects which we put on it’s own Mediatemple server is displaying a MySQL connection error – again. Over the last week it’s been a constant on/off battle made many times worse by the very slow Mediatemple support.

Mediatemple Sport a Speedy 20Hr Response Time

It was acceptable to begin with, 5 hours for the first reply, 13 hours for the second that informed me there was a bigger issue (mediatemple always seem to have MySQL issues), 7 hours later they informed me the issue had been fixed.

25 hours later (yes, TWENTY FIVE), after I had replied saying there was still a problem, they told me it was all running ok…which it was THEN but it had been too slow to work for hours before they replied.

I should probably point out that all of this was mid-week so the only reason I can see for the slow responses is that everyone was busy working on the problem?

Mediatemple Support Home

In the past I have had timely replies to my tickets (2 hour average) which is not as good as some (VPSLatch and PowerVPS being the best I’ve seen) but decent. In fact the response time is estimated at 4 hours 28 mins in the control panel right now. I have had only one instance of downtime for my files but unfortunately there are a couple of other shortcomings of their system including overly complicated domain setup (for subdomains) and how they work with the system. Whereas cPanel (for example) has seperate stats and settings for each domain, Mediatemple’s control panel mixes them together so the Urchin stats show all sites as one.

This post isn’t completely one sided, as the amount of space & bandwidth you’re given is very generous; along with the actual computing ‘budget’ they provide you with being pretty high (with their GPU system). Their website is beautifully designed and works pretty well but is let down by their MySQL system and slightly confusing control panel. You can of course fix the MySQL fault by purchasing a MySQL container at $20/mo, offering excellent response times; but this doubles the monthly cost of the service.

Extra MySQL Packages Are Available

I’d also point out that the Mediatemple terms of use are similar to those found on VPS and dedicated servers, much more relaxed than shared servers. This is still very useful (combined with the high storage space and inclusive bandwidth) for image hosting sites etc that you can’t put elsewhere.

Hopefully this has given you a fairly round view of my time with mediatemple, everybody’s views differ and you’ll have a different experience depending on what cluster you’re on; but I’d suggest a VPS is a better way to go until Mediatemple sort out the annoying MySQL lag.

Automatic Local, FTP & Email Backups of MySQL Databases with Cron

I’ll start by saying this is not all my own code, it is based on dagon design’s original release in 2007 (Automatic MySql Backup Script) but this version builds on their version 2.1 to add FTP support.

What this script can do:

  • Backup all of your MySQL databases on a server individually, then package them into a single tar.
  • Save that tar locally, on a FTP server or even email it to you

What you need:

  • PHP
  • MySQL
  • Preferably the root mysql login & password (allows you to backup all databases in one go)

I do not guarantee:

  • That this will definately work on your server, or Windows servers out of the box.

However it is here for people to use. I have tested it on several linux machines and it runs great.

Download:

Zip containing dbbackup.php & dbbackupconfig.php – dbbackup.zip

What I’ve added:

To upload to a remote FTP server, I added this to the config file:

######################################################################
## FTP Options
######################################################################

// Use FTP Option?
$useftp = true;

// Use passive mode?
$usepassive = true;

// FTP Server Address
$ftp_server = 'host';

// FTP Username & Password
$ftp_user_name = 'username';
$ftp_user_pass = 'password';

and this to the main file below email sending:

// do we ftp the file?
if ($useftp == true) {
$file = $BACKUP_DEST.'/'.$BACKUP_NAME;
$remote_file = $BACKUP_NAME;

// set up basic connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// turn passive mode on?
ftp_pasv($conn_id, $usepassive);

// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_BINARY)) {
 echo "successfully uploaded to ftp: $remotefile\n";
} else {
 echo "There was a problem while uploading $remotefile\n";
}

// close the connection
ftp_close($conn_id);
}

That’s all!

Simple Math – Updating MySQL Prices by a Percentage (And rounding)

The other day we had the simple request from a client – they asked us to update every price on their site. They asked us to increase their prices on ALL their products by 8%.

This is a simple bit of SQL which updates all the numbers in a field by a percent.

Let’s say our database is called catalog.

Our table is called products.

Our field is called products_price.

So the query on the catalog database would be:

UPDATE products SET products_price = products_price * 1.08

Simple! ‘UPDATE products’ tells the database which table we’re talking about, and ‘SET products_price’ will alter every value in the table in the ‘products_price’ field.

Then, we say ‘products_price = products_price * 1.08’, which simply says that the each value for products_price will be 1.08 times the current value. As we know, a value * 1.08 is 8% bigger.

But wait! That’s given us some nasty prices – for example,

523.99 * 1.08 = 565.9092

4 decimal places? We could use the ROUND function to round our values to 2 decimal places.

UPDATE products SET products_price = ROUND ( products_price , 2 )

I’ve kept it in the same format as above so you can see how it is used. This will round all values to 2 decimal places. Now, to run both queries at the same time:

UPDATE products SET products_price = ROUND ( products_price * 1.08 , 2 )

Easy! That’s updated all your prices in a couple of seconds. This was run on a site using ZenCart – that’s where the database structure is from, while the query was run in phpMyAdmin.