Usage of PostgreSQL in ubuntu

Source: Internet
Author: User
Tags postgresql psql create database

Simple description

Path

The code is as follows: Copy code

/Var/lib/postgresql/9.3/
View version

Psql -- version

Create User

Example: create a yy user with the password yy, create a blogbase database, and grant all permissions to the yy user

The code is as follows: Copy code

$ Sudo su-postgres
$ Psql
S = # create user yy with password 'yy ';
CREATE ROLE
Postgres = # create database blogbase;
CREATE DATABASE
Postgres = # grant all privileges on database blogbase to yy;
GRANT
Change user password

Alter user username with password 'new password ';
ALTER ROLE
Log on to the database

Psql-U yy-d blogbase-h 127.0.0.1
-U: specifies the user,-d: specifies the database,-h: specifies the server, if any port is specified with-p

After executing the preceding command, if a statement such as "Password for user yy:" is displayed, you can enter the Password. After entering the Password, the logon is successful.

Rename a database

Alter database blogbase rename to blogbase1;
Service

# Viewing status
Sudo/etc/init. d/postgresql status

# Start
Sudo/etc/init. d/postgresql start

# Stop
Sudo/etc/init. d/postgresql stop

# Restart
Sudo/etc/init. d/postgresql restart

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.