asqft app one square foot work in progress, ec2 instance, postgres


creating user
sudo -u postgres createuser
ex: sudo -u postgres createuser asqft;

creating database
sudo -u postgres createdb
ex: sudo -u postgres createdb asqft;

giving the use a password
sudo -u postgres psql
psql# alter user with encrypted password '';

---
https://askubuntu.com/questions/820792/peer-authentication-failed-for-user-with-all-privileges-in-postgres-9-5
sudo service postgresql restart
Open /etc/postgresql/9.5/main/pg_hba.conf with root access

 sudo nano /etc/postgresql/9.5/main/pg_hba.conf
Change peer to md5 in these lines.

Before changing

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            peer
# IPv6 local connections:
host    all             all             ::1/128                 peer
After your change

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
Save the file with pressing Ctrl-O. Exit nano with Ctrl-X

Restart postgresql using

sudo service postgresql restart

granting privileges on database
psql# grant all privileges on database to  ;

ex: grant all privilege on database asqft to asqft;

-----
sudo -u postgres psql

Q)How to changes user in ubunt?
A)
sudo -i -u postsgres
createdb
ex: createdb asqft

Q)How to create user in Ubuntu?
A)
createuser --interactive


Q)Connect to the database in postgres?
A)
psql -d postgres

psql -d

\conninfo
#for details about the connection

Q)How to see the list of tables and other details of the current database?
A)
# with sequence
\d

# without sequence
\dt

Q)How to start phoenix framework application?
A)
#go to the application folder
mix phx.server

No comments:

Post a Comment