Log in to the PostgreSQL database console
psql database name
Login successful Display
[zpf@kevin ~]$ psql postgres
psql (9.4.1) Type "help" for help.
postgres=#
Create DATABASE User xxx
CREATE USER xxx WITH PASSWORD ‘xxxxxx‘;
Create a database yyy and specify the owner as xxx
CREATE DATABASE yyy OWNER xxx;
Assign all operation permissions to the database yyy to user xxx, otherwise xxx can only log in to the console without any database operation permissions
GRANT ALL PRIVILEGES ON DATABASE yyy to xxx;
Delete Database yyy
DROP DATABASE yyy;
Delete User xxx
DROP USER XXX;
Exit Psql Console
\q
Common other commands
\ h: View the explanation of SQL commands, such as \ h select.
\ ?: View the list of psql commands.
\ l: List all databases.
\ c [database_name]: Connect to another database.
\ d: List all tables in the current database.
\ d [table_name]: List the structure of a table.
\ du: List all users.
\ e: Open a text editor.
\ conninfo: List information about the current database and connection.
\ password uesrname: Modify the database user password.
Note: Basic database operations must be uppercase, such as Create,select.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
PostgreSQL Database psql Console action command