title: Grant privileges for a particular database in PostgreSQL
body: <p>I'm moving from MySQL to PostgreSQL and have hit a wall with user privileges. I am used to assigning a user all privileges to all tables of a database with the following command:</p>
  
  <pre><code># MySQL
  grant all privileges on mydatabase.* to 'myuser'@'localhost' identified by 'mypassword';
  </code></pre>
  
  <p>It appears to me that the PostgreSQL 9.x solution involves assigning privileges to a "schema", but the effort required of me to figure out exactly what SQL to issue is proving excessive. I know that a few more hours of research will yield an answer, but I think everyone moving from MySQL to PostgreSQL could benefit from having at least one page on the web that provides a simple and complete recipe. This is the only command I have ever needed to issue for users. I'd rather not have to issue a command for every new table.</p>
  
  <p>I don't know what scenarios have to be handled differently in PostgreSQL, so I'll list some of the scenarios that I have typically had to handle in the past. Assume that we only mean to modify privileges to a single database that has already been created.</p>
  
  <blockquote>
    <p>(1a) Not all of the tables have been created yet, or (1b) the tables have already been created.</p>
    
    <p>(2a) The user has not yet been created, or (2b) the user has already been created.</p>
    
    <p>(3a) Privileges have not yet been assigned to the user, or (3b) privileges were previously assigned to the user.</p>
    
    <p>(4a) The user only needs to insert, update, select, and delete rows, or (4b) the user also needs to be able to create and delete tables.</p>
  </blockquote>
  
  <p>I have seen answers that grant all privileges to all databases, but that's not what I want here. Please, I am looking for a simple recipe, although I wouldn't mind an explanation as well.</p>
  
  <p>I don't want to grant rights to all users and all databases, as seems to be the conventional shortcut, because that approach compromises all databases when any one user is compromised. I host multiple database clients and assign each client a different login.</p>
  
  <p>It looks like I also need the <code>USAGE</code> privilege to get the increasing values of a <code>serial</code> column, but I have to grant it on some sort of sequence. My problem got more complex.</p>