The worst typo in MySQL query ever

Well, today I’ve learned something new.  Typing a query like this:

UPDATE `table` SET `field` = '1' WHERE `id` = '123'

I made a typo and entered the following:

UPDATE `table` SET `field` = '1' WHERE `id` - '123'

Yup.  A simple dash (-) instead of an equal (=) sign.  I know, I’m supposed to do a SELECT before, or use a transaction, or, at least, have a backup of the database – depending on which school of thought you follow the most.  I didn’t have any of these.  And once the query went in, there was little I could do.

Guess what the query does?  I’m still looking into the exact consequences, but so far it looks like ALL records EXCEPT the one with id 123 have been updated.

Gladly I have some history revision tables from which I could restore most of the state.  But this is scary dangerous anyway.  I would expect a syntax error intuitively.

–i-am-a-dummy

Here is a handy command-line option for MySQL client: –i-am-a-dummy, or, if you don’t have a sense of humor, –safe-updates.  When used, this will prevent updating or deleting rows without explicitly specifying a WHERE clause.  It will also limit the number of SELECT and JOIN results.

Fixing MySQL error “Cannot load from mysql.proc. The table is probably corrupted”

Fixing MySQL error “Cannot load from mysql.proc. The table is probably corrupted”

After a recent upgrade of some of my CentOS 6.3 servers to MySQL 5.5 from the Remi repository, I started noticing errors like this one in the logs, especially during backups:

MySQL: SHOW FUNCTION STATUS WHERE Db = ‘name’: Cannot load from mysql.proc. The table is probably corrupted

A quick search revealed that this is do to ‘mysqld_upgrade’ script not being run automatically against the existing database.  A quick and simple solution is to just run the script manually.  Of course, a full database backup is recommended before doing so.  Mine worked just fine though.

Economic impact of open source on small business

Economic impact of open source on small business

Here are a few of the findings we derived from Bluehost data (an EIG company) and follow-on research:

  • 60% of web hosting usage is by SMBs, 71% if you include non-profits. Only 22% of hosted sites are for personal use.
  • WordPress is a far more important open source product than most people give it credit for. In the SMB hosting market, it is as widely used as MySQL and PHP, far ahead of Joomla and Drupal, the other leading content management systems.
  • Languages commonly used by high-tech startups, such as Ruby and Python, have little usage in the SMB hosting market, which is dominated by PHP for server-side scripting and JavaScript for client-side scripting.
  • Open source hosting alternatives have at least a 2:1 cost advantage relative to proprietary solutions.

Given that SMBs are widely thought to generate as much as 50% of GDP, the productivity gains to the economy as a whole that can be attributed to open source software are significant. The most important open source programs contributing to this expansion of opportunity for small businesses include Linux, Apache, MySQL, PHP, JavaScript, and WordPress. The developers of these open source projects and the communities that support them are truly unsung heroes of the economy!

Via Matt Mullenweg.