Access denied error when logged in as admin

In my case it happend that the capability for user 1 somehow got wiped, so the SQL command:
INSERT INTO wp_usermeta (user_id, meta_key, meta_value)
VALUES(1,”wp_capabilities”,’a:1:{s:13:”administrator”;b:1;}’);
did the trick.