CreateDB: Error: Local user with ID 1001 does not exists

Solution

If you encounter the error "createDB: Error: Local user with ID 1001 does not exists" while trying to create a new database in PostgreSQL, follow these steps to fix the issue:

Execute the command as the user postgres instead of your current user. For example, to create a new database named chirpns, run:

createdb -U postgres chirpns

This command creates a new database named chirpns with the user postgres as the owner. You can replace chirpns with the name of your desired database.

Note: If you don't know the password for the postgres user, you can reset it by running:

sudo -u postgres psql \password postgres

This will prompt you to enter a new password for the postgres user.