sudo -u postgres psql -d db223 // log in as super admin
3. 查看数据表
所有数据表 \d
单个表 \d tablename
更多信息 \d+ tablename
\dt \di 索引 \ds 序列 \dv 视图 \df 函数
4. 显示sql 执行的时间
\timing on sql
5. 列出所有的角色和用户
\du \dg
6. 把每行中每列数据拆成单行数据显示
\x
7. 执行外部存储sql
\i
8. postgres 默认自动提交
\set AUTOCOMMIT off
9. psql 更改密码
a
PostgreSQL默认的超级管理员密码是postgres 连接方法: su - postgres 或 sudo su - postgres psql -U postgres(注意,是大写的-U)默认密码为空 修改密码的方法是,用psql登入管理:psql -U postgres 然后用这样的命令来修改密码:alter user postgres with password 'new password' b
首先打开data目录下的pg_hba.conf配置文件,找到:
# IPv4 local connections: host all all 127.0.0.1/32 md5