cygwin下使用postgreSQL

前端之家收集整理的这篇文章主要介绍了cygwin下使用postgreSQL前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.安装

运行Cygwin的安装程序setup.exe,选中以下组件

Database/

|--postgresql
@H_502_10@
@H_502_10@进行安装。

2.设置

环境变量的设置

在~/.bashrc中添加如下内容

export CYGWIN=server@H_502_10@

export PGDATA=/usr/local/pgsql/data@H_502_10@

export PGCLIENTENCODING=EUC_CN@H_502_10@
@H_502_10@
@H_502_10@在~/.bash_profile中添加如下内容

PATH="/usr/sbin:/sbin:${PATH}"

export PATH
@H_502_10@
运行

$ source ~/.bashrc@H_502_10@

$ source ~/.bash_profile@H_502_10@
@H_502_10@
让刚才的设置生效。

cygserver的设置

运行

$ cygserver-config
@H_502_10@
看到提示yes/no的时候,输入yes,回车。

启动cygserver

$ cygserver &
@H_502_10@
初始化数据库

$ initdb --no-locale --encoding=EUC_CN

@H_502_10@3.启动

$ pg_ctl start @H_502_10@

之前须确认cygserver是否启动了。

4.创建用户数据库

运行

$ createuser -d -a root (@H_502_10@@H_502_10@创建用户root@H_502_10@)@H_502_10@

$ createdb -U root -O root test (创建数据库,用户和所有者都是root)@H_502_10@

5.使用数据库

$ psql test root@H_502_10@@H_502_10@

如正常,即出现postgresql提示符.

test=# \?@H_502_10@@H_502_10@ (即出现postgresql的常用命令) @H_502_10@

@H_502_10@

test=# create table people (@H_502_10@

test-# first_name varchar,@H_502_10@

test-# last_name varchar@H_502_10@

test-# );
@H_502_10@

test=# insert into people values ('wang','wu');@H_502_10@

test=# select * from people;@H_502_10@

first_name | last_name
--------------+---------------
wang | wu@H_502_10@

test=# \q@H_502_10@ (退出Postgresql提示符的命令) @H_502_10@@H_502_10@

6.停止

$ pg_ctl stop@H_502_10@

即停止Postgresql数据库服务。

7.补充

安装过程比较有可能出问题的是initdb的时候。如果出错,请运行

$ rm -rf /usr/local/pgsql/data@H_502_10@@H_502_10@

删除数据路径,解决问题后再运行initdb。


psql语法
\h 查看sql语法
\? 查看psql语法

\du 查看所有的用户

\l 查看所有的数据库 \z 查看当前所有的数据表,视图

猜你在找的Postgre SQL相关文章