Last active
January 31, 2018 11:30
-
-
Save pvin/be483c392e11971d669bf265d1d27866 to your computer and use it in GitHub Desktop.
psql
This file contains 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
login with peer authondication | |
sudo -u postgres psql | |
login with md5 | |
Then type: | |
sudo -u postgres psql | |
Then: | |
\password postgres | |
Then to quit: | |
\q | |
If that does not work, reconfigure authentication. | |
Edit /etc/postgresql/9.1/main/pg_hba.conf (path will differ) and change: | |
local all all peer | |
to: | |
local all all md5 | |
Then restart the server: | |
sudo service postgresql restart | |
list | |
\list | |
create user | |
postgres=# CREATE USER project_user WITH PASSWORD 'passeddfdsword'; | |
create db | |
postgres=# CREATE DATABASE project_db OWNER project_user; | |
dumping | |
$ pg_dump -h localhost project_db -U project_user > database_dump.sql | |
undumping | |
$ psql -h localhost -d project_db -U project_user < PostgreSQL.sql | |
restart | |
$ sudo service postgresql restart | |
https://stackoverflow.com/questions/12720967/how-to-change-postgresql-user-password |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment