Skip to content
mengfung.com
writing

CentOS 7 and PostgreSQL 9.3

 ·  1 min read

Process to install and initialize.

# ssh into server
cd
curl -O http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/pgdg-centos93-9.3-1.noarch.rpm
# add to yum
rpm -ivh pgdg*
yum list postgres
yum install postgresql93-server
# initialize database
/usr/pgsql-9.3/bin/postgresql93-setup initdb
# start database
systemctl start postgresql-9.3 # or service postgres-9.3 start
# caveat make sure postgres owns and can write to the directory where the db files are stored.
# /var/lib/pgsql/9.3/data
# if not
# chown -Rf postgres:postgres /var/lib/pgsql/9.3/data
# chmod 700 /var/lib/pgsql/9.3/data/
# then run start command
# switch to postgres user
su - postgres
psql
# quit
\q
# create a user that can create databases (-d can create databases -R can't create roles -P prompt for password)
createuser -d -R -P username
# kill user session
exit