整理使用postgres需要设置和常用命令

export PATH=/usr/lib/postgresql/9.1/bin:$PATH:/usr/sbin export PGDATA=/var/lib/postgresql/9.1/main export PGPORT=5432

  
  
  
  
PGDATA

Default data directory location

postgres -D /usr/local/pgsql/data other-options my_database

Provide the correct path to the database directory with -D, or make sure that the environment variable PGDATA is set. Also specify the name of the particular database you want to work in.


postgres@s:~$ su - postgres 
postgres@s:~$ psql scotzilla 

error and solve:

  1. createuser: creation of new role failed: ERROR: role "acotzilla"already exists
  2. dropuser scotzilla

pg_restore - 从一个由 pg_dump 创建的备份文件中恢复 PostgreSQL 数据库。
    
    
    
    
  1. tail /var/log/postgresql/postgresql-9.1-main.log //查看日志错误输出
  2. ~# /etc/init.d/postgresql start //启动数据库


你可能感兴趣的:(整理使用postgres需要设置和常用命令)