mysqldump: dump rows matching certain criteria, or limit number of dumped rows

To limit the number of rows dumped by mysqldump, you can do:

mysqldump -u [user] -p[password] --where="true LIMIT 5" [database] [tablename] > outputfilename.sql

You could select other criteria as well:

mysqldump -u [user] -p[password] --where="userid > 24" [database] [tablename] > outputfilename.sql


Drupal fatal error: cannot redeclare function()

Ever seen this when in Drupal’s administration pages?

Fatal error: Cannot redeclare getnodecount() (previously declared in /var/www/sites/ : eval()'d code:3) in /var/www/sites/ : eval()'d code on line 9

There are a few causes for this, as mentioned on, but the one in which you might be interested (because your error message looks more similar to mine, above, than to the documentation) is when PHP is actually contained in a block or node body. That’s something you should suspect if you see the above error message referring to PHP’s eval() function.

To fix this, do something in MySQL like

FROM node_revisions
WHERE body LIKE '%getnodecount%';

And edit the offending nodes in Drupal with a URL such as