> For the complete documentation index, see [llms.txt](https://dev-notes.vinguyen.blog/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev-notes.vinguyen.blog/notes/deployment-and-operation/database/postgresql/postgresql-create-user-and-grant-permission-on-a-database.md).

# PostgreSQL - Create user & grant permission on a database

#### Snippets

```sql
CREATE USER your_username;
ALTER USER your_username WITH ENCRYPTED PASSWORD 'your_password';

CREATE DATABASE your_database_name;

// Grant all PRIVILEGES
GRANT ALL PRIVILEGES ON DATABASE your_database_name TO your_username;

// Grant Readonly
GRANT SELECT, SHOW VIEW ON `your_database_name`.* TO 'your_username' @ '%';

```

#### Referrence

* <https://www.postgresql.org/docs/8.0/sql-createuser.html>
