Drupal 'Access Denied' errors for anonymous user

Drupal can be a pain. After a whole day of development, we started getting 'Access Denied' errors on all content that should be accessible by the anonymous user. The cause turned out to be something to do with a module incorrectly altering the node_access table.

Running this query fixed it:

insert into node_acccess(nid, gid, realm, grant_view, grant_update, grant_delete) values('0', '0', 'all', '1', '0', '0');

The solution was in the Access denied to anonymous users thread (comment #9) on the Drupal Issues.