Last active
July 29, 2017 20:09
-
-
Save yoyozi/39c5d490fbbeda70d83f88a1503e52b8 to your computer and use it in GitHub Desktop.
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
Create a Postgres user for the Rails app, switch into the Postgres user: | |
> sudo su postgres | |
Then login to the databse "postgres" with the adn\min of "postgres" | |
> psql -d postgres -U postgres | |
or > sudo -u postres psql | |
Then create a user (or a "role", as Postgres calls it): | |
create role myapp with createdb login password 'password1'; | |
> ALTER user myapp with superuser; | |
> psql postgres | |
# create database test; | |
\l list databases | |
\c connect to database | |
To drop \c to another ie: postgres then : drop database test; | |
\q | |
If "peer authentication" does not work, try md5 authenticaion by editing conf file | |
vim /etc/postgresql/"pg_version"/main/pg_hba.conf | |
peer is local socket MD5 is using postgres username | |
To specify host try something like this: | |
> psql -d <dbname> -U <username> -h <hostname> | |
or this: | |
> psql -d <dbname> -U <username> -h <hostname> -W | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment