PostgreSQL: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
No edit summary
Line 3: Line 3:
su - postgres
su - postgres
# Last login: Mon Apr 16 10:26:05 MYT 2018 on pts/0
# Last login: Tue Jan 01 12:00:00 MYT 2013 on pts/0
# -bash-4.2$
# -bash-4.2$
psql
psql
Line 16: Line 16:
su - postgres psql
su - postgres psql
# Last login: Mon Apr 16 10:25:10 MYT 2018 on pts/0
# Last login: Tue Jan 01 12:00:00 MYT 2013 on pts/0
# /bin/createuser: /bin/createuser: cannot execute binary file
# /bin/createuser: /bin/createuser: cannot execute binary file
</syntaxhighlight>
</syntaxhighlight>
Line 24: Line 24:
su - postgres
su - postgres
# Last login: Mon Apr 16 10:26:05 MYT 2018 on pts/0
# Last login: Tue Jan 01 12:00:00 MYT 2013 on pts/0
# -bash-4.2$
# -bash-4.2$
createuser root
createuser root
Line 35: Line 35:
su - postgres
su - postgres
# Last login: Mon Apr 16 10:26:05 MYT 2018 on pts/0
# Last login: Tue Jan 01 12:00:00 MYT 2013 on pts/0
# -bash-4.2$
# -bash-4.2$
createdb root
createdb root

Revision as of 20:54, 15 April 2018

Login to Postgres

# [email protected]:~ #
su - postgres
# Last login: Tue Jan 01 12:00:00 MYT 2013 on pts/0
# -bash-4.2$
psql
# psql (9.6.8)
# Type "help" for help.
# 
# postgres=#

Login Error

# [email protected]:~ #
su - postgres psql
# Last login: Tue Jan 01 12:00:00 MYT 2013 on pts/0
# /bin/createuser: /bin/createuser: cannot execute binary file

Creating User

# [email protected]:~ #
su - postgres
# Last login: Tue Jan 01 12:00:00 MYT 2013 on pts/0
# -bash-4.2$
createuser root
# createuser: creation of new role failed: ERROR:  role "root" already exists

Creating Database

Until creating root database it's always show error could not change directory to "/root": Permission denied. To overcome this error we should need to create a root database. only for avoid error while login using root user.

# [email protected]:~ #
su - postgres
# Last login: Tue Jan 01 12:00:00 MYT 2013 on pts/0
# -bash-4.2$
createdb root

Grant Privileges

# postgres=#
grant all privileges on database root to root;
# GRANT
# postgres=#
grant all privileges on database postgres  to root;
# GRANT