Archive for the ‘PostgreSQL’ Category

postgres常用命令

Thursday, August 23rd, 2007




启动postgres: postmaster -D /usr/local/pgsql/data -i & 停止:/pg-ctl -m immediate -D /usr/local/pgsql/data stop 进控制台: /bin/psql -Upostgres databaseName \d 看表 \dt tablename \l 列出数据库 \du 看用户 导入导出:pg_dump,pg_restore ./pg_dump -i -h localhost -p 5432 -Upostgres -F p -D -v -f "/home/user/dump.sql"  databaseName 用pg_dump倒,数据库中无大对象可以(文本格式的):pg_dump 库名>文件名; 有大对象的也可以:pg_dump -o -Ft -b 库名>文件名; 创建数据库:createdb 创建数据库的时候,如果出现如下错误: C:\Program Files\PostgreSQL\8.0\bin>createdb -Upostgres newdb createdb:建立資料庫失敗:ERROR: ...

RedHat Linux 安装 PostgreSQL 8.4.2

Monday, August 6th, 2007




下载并解包 $ tar zxvf postgresql-8.2.4.tar.gz $ cd postgresql-8.2.4 配置 $ ./configure --prefix=/usr/local/pgsql-8.2.4   ...   config.status: linking ./src/makefiles/Makefile.linux to src/Makefile.port 编译 $ make   ...   All of PostgreSQL successfully made. Ready to install. 测试 $ make check   ...   =======================    All 103 tests passed.   ======================= 安装(root) # su - # groupadd postgresql # useradd -g postgresql postgresql # cd <安装目录> # make install   ...   PostgreSQL installation complete. # ...

开始学习PostgreSQL

Thursday, August 2nd, 2007




因为工作的关系,要开始学习一下PostgreSQL,刚刚配置了一下环境,笔记一下,免得忘记。 我是在Windows上安装的PostgreSQL,它的安装程序已经做得足够简单了,只要一直点“下一步”就ok了,我做的唯一修改就是把超级用户的名字从默认的postgres改为了root(因为我MySQL用惯了),安装完后,使用自带的pgAdmin就可以管理数据库了(需要修改一下属性,把缺省的postgres用户改为root)。 ------------------------------------------------------------------------- 我在管理MySQL的时候,一般习惯用web界面的phpmyadmin来操作,所以,在管理PostgreSQL的时候,我多少还是不习惯 pgAdmin,于是我下载了一个phppgadmin,和phpmyadmin类似,可是在连接数据库的时候出现了问题,一直告诉我: Login disallowed for security reasons. 最后在查阅相关文档后,找到了问题所在,原来在配置文件conf\config.inc.php中,默认有如下设置: // If extra login security is true, then logins via phpPgAdmin with no // password or certain usernames (pgsql, postgres, root, administrator) // will be denied. Only set this false once you have read the FAQ and // understand how to change PostgreSQL's pg_hba.conf to enable // passworded local ...