ERROR 1221 (HY000) While Revoking Super

I’ve been working with MySQL Master-Slave replication at work a LOT recently and one of the things that you have to do on read-only slaves is to revoke the super access to the user access the slave so it doesn’t write data.

I normally setup users like this because it’s easy and it gives the user all the access they need:

mysql> grant all on tasks.* to 'taskuser'@'localhost';

So when I tried to revote super I got the following error:

mysql> revoke SUPER on tasks.* from 'taskuser'@'localhost'; 
ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES 

The super permission can’t be revoted on a specific database it has to be revoted on ALL databases:

mysql> revoke super on *.* from 'taskuser'@'localhost';

Again another hour of my life that can’t be returned. :-)

Fixing the “No recipient forward path has been supplied” in Zend_Mail

I keep running into a problem where I get the error “No recipient forward path has been supplied” when a cron job tries to send emails. It’s been a huge pain to figure out, and I finally tracked it down to a specific user and when I var_dumped the emails involved I found the following:

string '' (length=17)

I trimed the space out and it started working! I’ll never get that 2 hours of my life back. :-)

Podcast About Atom-Shell

The Hanselminutes Podcast has an interesting interview with Paul Betts where they talk about Atom Shell which is based off the interface the Atom Text Editor uses. It’s Node.js and Chromium based and cross platform so it’s an interesting pick for those of us who need to develop a desktop app.

Podcast Link:

Atom Shell Starter Project on GitHub:

I haven’t actually tried the program but it’s on my long list of technologies to try out. :-)

Link Post: Getting Past Junior

I love this:

Whether I’m working on a kata or a breakable toy or even production software; I throw away most of the code I write. Why? Because my first attempt is a poor attempt. I use my first pass as a “spike”, a kind of hands-on learning opportunity.

and this:

Turning the knob to 11 is when you take a very specific concept; and over-apply it. Over-applying a technique or technology is the easiest way to find its shortcomings. Want to learn to TDD? TDD everything for a year. At the end you’ll have a solid understanding of when to and when not to TDD.

Installing Node.js on Ubuntu

I’m slowly working on integrating gulp into my workflow for a lot of projects and Ubuntu comes with an older version of Node.js (I’m guessing most distros do) and I wanted to have a more current version on my VMs. The process is actually very straight forward:

cd ~
tar -xzvf node-v0.12.0.tar.gz
cd node-v0.12.0
sudo make install

We want to make sure that we’re using the same version on all our VMs so we saved this process as a script so we could make sure we’re using the same version.

If you want to upgrade to a newer version make sure you delete your existing install first. We found it caused random problems if we didn’t:

rm -r bin/node bin/node-waf include/node lib/node lib/pkgconfig/nodejs.pc share/man/man1/node.1

Link Post: How to handle a client comparing your hourly rate to cheap overseas development

Maintainability. If it needs to be maintainable, it needs to be built right. Good documentation, automation where possible, proper subversioning, and well commented code. I spoke with a potential client for our corporate skunkworks program the other day who spoke with a developer who didn’t know what Git was. Regardless of your tool of choice (Git, Mercurial, or any other tool) – you should know what they all are and their importance.

It doesn’t even have to be overseas. I’ve seen a lot of crappy code from people in the US that didn’t know what they were doing and won a bid because they were the cheapest.

Working With json_extract on Ubuntu

JSON is awesome because it provides an amazing way for you to send information from one place to another and be guaranteed that it can be decoded by whatever language is on the other end. It’s also awesome because it’s schema-less and can easy adapt to hold any data. It just sucks when someone starts entering it into a database and you need to get it out.

Please note that I’m not recommending you EVER put JSON into a database column. This is a quick fix but it’s going to bite you in the butt later and someone is going to have to clean it up. :-)

One of the products I inherited has several JSON fields in a MySQL database that contain important information that we needed to created a report on. The end goal is to rewrite the sections of the code that read to and write from these columns but they’re important and most of the site actually uses it (we found over a thousand places where it’s referenced). As a quick fix we found mysqludf_json_extract which allows you to extract specific information from JSON encoded data in a database.

My favorite part about this project is it’s description:

if you thought it was a good idea to put json blobs in mysql and are living with the consequences

It reminds me of this comment about regular expressions:

Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems.


I had to install the mysql header files (libmysqlclient-dev) and cmake before I got started:

sudo apt-get install cmake libmysqlclient-dev 

mysqludf_json_extract hasn’t been updated in a while (4 years when I wrote this) and it has a dependency(yajl) that has been updated recently. You need to make sure you build the 1.x branch.

git clone 
cd yajl/ 
git checkout 1.x 
cmake . 
make sudo make install

I also found that on Ubuntu you need to copy the library to /usr/lib for it to work correctly:

sudo cp /usr/local/lib/ /usr/lib/

Finally, when you install you need to specify MYSQL_HOME and MYSQL_CONFIG

git clone 
cd mysqludf_json_extract 
set MYSQL_HOME = /usr/lib/mysql/ 
set MYSQL_CONFIG = /usr/lib/mysql/ 
cmake . 
make test 

Again, also found that on Ubuntu you need to copy the library to /usr/lib for it to work correctly:

sudo cp src/ /usr/lib/mysql/plugin/

Finally, you need to setup the function in MySQL.

mysql> drop function json_extract;
Query OK, 0 rows affected (0.00 sec)
mysql> create function json_extract returns string soname '';
Query OK, 0 rows affected (0.00 sec)

Then you can use it just like any other function:

mysql> select json_extract("a", val) result from foo;

We’ve been using mysqludf_json_extract for several months now and the only real problem we’ve run into is if we try to perform a where on a field inside a JSON blob it can stop the query. We just told people it doesn’t work that way. :-)

In closing, don’t do this. It’s a hung pain in the ass.

Fixing CMake was unable to find a build program corresponding to “Unix Makefiles”

Today I was trying to install mysqludf_json_extract on a new server and I ran into the following error:

$ cmake .
CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMake Error: Could not find cmake module file:/home/swarren/yajl/CMakeFiles/CMakeCCompiler.cmake
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

I thought this was a very cryptic error message but it turns out I just needed to install make:

sudo apt-get install make