加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql relate

发布时间:2020-12-13 17:00:25 所属栏目:百科 来源:网络整理
导读:create user:CREATE USER davide WITH PASSWORD 'jw8s0F4'; Examples To create a new database: CREATE DATABASE lusiadas; To create a database sales owned by user salesapp with a default tablespace of salesspace : CREATE DATABASE sales OWNER sa
create  user:

CREATE USER davide WITH PASSWORD 'jw8s0F4';



Examples

To create a new database:

CREATE DATABASE lusiadas;

To create a database sales owned by user salesapp with a default tablespace of salesspace:

CREATE DATABASE sales OWNER salesapp TABLESPACE salesspace;

To create a database music which supports the ISO-8859-1 character set:

CREATE DATABASE music ENCODING 'LATIN1' TEMPLATE template0;
CREATE DATABASE zulip ENCODING 'utf8' OWNER zulip;


Examples

Change a user's password:

ALTER USER davide WITH PASSWORD 'hu8jmn3';

Change the expiration date of the user's password:

ALTER USER manuel VALID UNTIL 'Jan 31 2030';

Change a password expiration date,specifying that the password should expire at midday on 4th May 2005 using the time zone which is one hour ahead of UTC:

ALTER USER chris VALID UNTIL 'May 4 12:00:00 2005 +1';

Make a password valid forever:

ALTER USER fred VALID UNTIL 'infinity';

Give a user the ability to create other users and new databases:

ALTER USER miriam CREATEUSER CREATEDB;


 fe_sendauth: no password supplied

给dbuser设置登录密码(之前没设置密码的时候登录报这个错psql: fe_sendauth: no password supplied,设置了就ok了)
root@i-1lb6pxls:/home/ubuntu/campo/shared# sudo -u postgres psql
psql (9.4.4)
Type "help" for help.

postgres=# password dbuser
Enter new password: 
Enter it again: 
postgres=# q

change to trust in pg_hba.conf 


接下来需要讲数据库uppers_staging 的所有权限都赋给dbuser,否则dbuser只能登录控制台,没有操作数据库的权限

 GRANT ALL PRIVILEGES ON DATABASE zulip to zulip;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读