PostgreSQL: Difference between revisions
Jump to navigation
Jump to search
Line 30: | Line 30: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Creating | == Creating DB == | ||
Until creating '''root database''' it's always show error <code>could not change directory to "/root": Permission denied</code>. To overcome this error we should need to create a '''root database'''. only for avoid error while login using '''root user'''. | Until creating '''root database''' it's always show error <code>could not change directory to "/root": Permission denied</code>. To overcome this error we should need to create a '''root database'''. only for avoid error while login using '''root user'''. | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> |
Revision as of 21:17, 15 April 2018
Login to PSQL
# [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 DB
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
Similarly you can create a database as same as your frequently used OS User. In this case no need password to login. It will authenticated from OS. That's means you can login to your PostgreSQL user using OS Authentication.
Grant Privileges
# postgres=#
grant all privileges on database root to root;
# GRANT
# postgres=#
grant all privileges on database postgres to root;
# GRANT
Logout PSQL
# postgres=#
\q
# -bash-4.2$