9.3.5 database, the system fedora20, different operating systems differ slightly.
Can be installed using the yum command:sudo yum install postgresql,postgresql-server
After installation, the system will create a user postgres, it switches to the user to initialize the database after:
1 |
initdb --encoding=UTF-8 --no-locale -D /var/lib/pgsql/data/ |
Or use postgresql-setup initdb command.
Then start the service:pg_ctl -D /var/lib/pgsql/data start
In order to facilitate the following actions, I reset a user's password postgres:
1 |
sudo passwd -d postgres |
Then postgres user permissions given to the implementation of sudo, set the boot from the start:
1 |
Start postgresql.service systemctl |
Then use the psql commands can be entered into the database of the terminal.
Before entering the terminal database we first create a database:createdb mytest
But every time you want to view the database will need to switch the user too much trouble, so then create a role account with the same name and usually use:
1 |
CREATE ROLE myuser WITH SUPERUSER LOGIN PASSWORD '123456'; |
I am here in order to save directly to the user as a superuser, other details see official documentation can be.
Then switch back to the normal use of the accounts linked to: psql -h localhost -U myuser mytest
(note the big U)
If you create a character above is a superuser or have the appropriate permissions, can also be executed directly createdb command to create the database.
Two configuration files used Location:
1 |
_ / var / lib / pgsql / data / postgresql.conf_ port and IP configuration |
This initial preparation is done.