Create new user and a database in PostgreSQL:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ su - postgres | |
$ psql template1 | |
template1=# CREATE USER tester WITH PASSWORD 'test_password'; | |
template1=# CREATE DATABASE test_database; | |
template1=# GRANT ALL PRIVILEGES ON DATABASE "test_database" to tester; | |
template1=# \q |
Now check that our new user has permissions to create new tables in the database.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
psql -h localhost -U tester -d test_database | |
test_database=> CREATE TABLE TESTME(ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL); | |
test_database=> DROP TABLE TESTME; | |
test_database=> \q |