Drop MySQL Tables by Table Prefix

Problem:

I’ve access to only 1 MySQL database, but I have multiple Magento Installations in it – so naturally, I’m using Table Prefixes to keep them separated. In my case, I have Magento Community Editions 1.6.2.0 and 1.7.0.2.

My table prefixes are ce1620_ and ce1702_, which is simple and easy to understand. The problem is how can I simply remove all tables for only 1 installation?

Solution:

The answer came in the form of a stored procedure. Most of the heavy lifting was done by a nice poster over on StackOverflow.

My little extra ingredient was to disable foreign key constraints, so I could obliterate the whole darn thing in one pass.

As always, be careful and back up before doing something as drastic as this.

DROP PROCEDURE IF EXISTS droplike;
delimiter //
CREATE PROCEDURE droplike(pattern VARCHAR(20))
BEGIN
 SET foreign_key_checks = 0;
 SET group_concat_max_len = 65535;
 SELECT @DROP:= concat( 'drop table ', group_concat(TABLE_NAME) , ';' ) FROM information_schema.TABLES WHERE table_schema = "YOUR_DATABASE_NAME_HERE" AND TABLE_NAME LIKE pattern;
 PREPARE statement FROM @DROP;
 EXECUTE statement;
 SET foreign_key_checks = 1;
END //
delimiter ;

Hopping off The Facebook Grid … for now, anyway

I hopped off the facebook grid today at around 5:30pm (Eastern).  The overarching reason is that facebook’s 80/20 rule is tilted in favor of crap I don’t care/ want to see being the 80%. That’s bad. Some specifics:

Politics
Stating your political beliefs is your choice, but it’s usually boring, uninformed, and so terse as to be impenetrable.

Work
Many people I’ve ‘friended’ are through work. They end up stating their political viewpoint, and (see also: Chick-fil-A) an argument ensues. You’re wrong. You’re right. In the end, it turns out that Our Context doesn’t include giving a rat’s ass about your politics, and suddenly the work relationship is fouled, or at least altered.

Relationships
All relationships have boundaries. Not so on facebook. You can argue with me and say, “well, you friended too many people,” or “you can organize your friends, blah blah blah” but when I go to work, I’m around my work friends, and at home I’m with my home friends. Some intersect. Some don’t. On facebook it’s all one big blur.

All Selling, All the Time
Selling yourself. Your work. Products. Games. Facebook is the modern junk mail.

What’s it For?
I have a blog. So I can write there. A little blog is lost among the bajillions of web sites out there, but so is any photo I have of my family’s vacation amidst the political grandstanding and organic chickens on facebook.

What’s Next
I’m still on Google+, which means I am still fairly anonymous. But the photography experience is far superior to facebook’s. The interface is a bit wobbly. It really should be a lot easier to post a message to my niece. Never make me undo things to do something, which Google+ is currently forcing me to do by defaulting where I want my message post seen.

Google+ iOS App vs. Facebook
Hard to believe I’m saying this, but Google+ iOS App is far more beautiful than facebook’s and – here’s the real rub – a lot faster. Why am I sitting here for minutes on end waiting for … all the stuff I mentioned above that I don’t really want to see?

Git missing in OSX Mountain Lion

Quick one today to remind others and perhaps my future self. After my upgrade to Mountain Lion, git was missing. Surprise!

Easy fix for me, obtained via https://answers.atlassian.com/questions/72981/error-after-upgrading-to-mountain-lion-os-git-svn …  (Thanks!)

In Xcode, we just go to Preferences > Downloads and click install next to “Command Line
Tools”:

Re-installing command line tools, git included!

Hope this helps! It certainly easier to git push when you actually have git ;)

TurnKey Linux LAMP Appliance – phpMyAdmin crashes/ won’t load

Frustration this evening updating my TurnKey Linux  LAMP appliance. Couldn’t get phpMyAdmin to load after update. Server error. Couldn’t track the darn thing down.

After a step by step “echo ‘here i am’” campaign, it came down to this: in /usr/share/phpmyadmin/config.inc.php, it was trying to “Load autoconf local config” from /var/lib/phpmyadmin/config.inc.php. Problem was /var/lib/phpmyadmin/config.inc.php was set to no read permission! Probably a result of some failed upgrade or something. I just don’t have time for this right now! Arg!

Anyway, chmod a+r (sudo or as root, etc) on /var/lib/phpmyadmin/config.inc.php did the trick.

UPDATE 2012-Aug-9: Doing some maintenance work on yet another virtual appliance, and not only was config.inc.php thus afflicted, so was blowfish_secret.inc.php. The above command plus this command fixed it:

sudo chmod a+r /var/lib/phpmyadmin/blowfish_secret.inc.php

Now, back to work.