Trying to get Postgres setup in my environment but can't seem to get permissions to intidb
This should work just fine:
# sudo mkdir /usr/local/var/postgres
# sudo chmod 775 /usr/local/var/postgres
# sudo chown construct /usr/local/var/postgres
# initdb /usr/local/var/postgres
use your username in place of construct. So, if your computer username is WDurant, the code will be:
# sudo chown $(whoami) /usr/local/var/postgres
If you run on Arch Linux, use like this :
sudo mkdir /var/lib/postgres
sudo chmod 775 /var/lib/postgres
sudo chown postgres /var/lib/postgres
sudo -i -u postgres
[postgres]$ initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data'
[postgres]$ exit
sudo systemctl start postgresql.service
sudo -i -u postgres
You actually need to SU
to the postgres
user
sudo su - postgres
then you can run the command
initdb -E UTF8
(I prefer setting this now because UTF8 is quite flexible and this will create all clusters as UTF8 [unless you explicitly specify otherwise])
then you need to create your user (if it hasn't already been created)
$ createuser -s -U postgres
$ Enter name of role to add: {{ my login name }}
(this appears to beConstruct
)
then you can exit out of postgres user and you can create your own database
$ createdb