How to fix the "You do not have the necessary rights to access this page" error?

This error message is manifold and can be caused from actual missing user rights, to missing file rights, to prefixes not being applied.
In my case I had admin rights, could log in so the admin bar was visible, but I couldn’t get to the dashboard or other backend pages.

Solution: the ID and name of the admin had to be changed, to ID 1 and administrator. Additionally the entry under wp_capabilities to be corrected to:

a:1:{s:13:"administrator";b:1;}