日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

postgreSQL入门01-安装

發布時間:2024/1/17 数据库 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 postgreSQL入门01-安装 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

? postgreSQL跟mysql,oracle,DB2,Sybase一樣,是一種數據庫。

oracle的命令行工具是sqlplus; kingbase的命令行工具是isql postgreSQL的命令行工具是psql mysql的命令行工具是mysql
postgreSQL是免費開源的數據庫軟件。 linux下的安裝和使用 1,安裝 安裝之前最好創建一個postgres用戶,命令如下: groupadd postgres useradd postgres –g postgres?
然后修改密碼 passwd postgres 需要在linux下安裝如下三個包:

postgresql-8.1.23-1.el5_7.3.i386.rpm(postgreSQL客戶端

?

postgresql-server-8.1.23-1.el5_7.3.i386.rpm(postgreSQL服務器

?

postgresql-libs-8.1.23-1.el5_7.3.i386.rpm

安裝命令如下:

yum install?postgresql-libs-8.1.23-1.el5_7.3.i386.rpm

yum install??postgresql-server-8.1.23-1.el5_7.3.i386.rpm

yum install??postgresql-libs-8.1.23-1.el5_7.3.i386.rpm

或者rpm -ivh?postgresql-8.1.23-1.el5_7.3.i386.rpm

rpm -ivh??postgresql-server-8.1.23-1.el5_7.3.i386.rpm?

rpm -ivh??postgresql-libs-8.1.23-1.el5_7.3.i386.rpm

?

安裝完成之后使用chkconfig命令查看postgreSQL服務器運行情況:

?

[root@localhost awk-study]# chkconfig --list|grep postgres

postgresql ? ? ?0:關閉 ?1:關閉 ?2:關閉 ?3:關閉 ?4:關閉 ?5:關閉 ?6:關閉

2,連接和使用 然后啟動服務:service?postgresql start postgresql?服務啟動之后,就可以連接postgresql服務器了,那么如何連接呢? 在linux 終端中 (1)切換用戶:?su - postgres (2)運行psql -d postgres postgres 參數說明: -d 是指定數據庫名 如下: [root@localhost ~]# su - postgres -bash-3.2$ psql -d?postgres?postgres前者是數據庫名稱后者是用戶名) Welcome to psql 8.1.23, the PostgreSQL interactive terminal. Type: ?\copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit 然后就可以進行各種操作了,如創建一個簡單的數據表: postgres=# \c 你現在是以用戶 "postgres" 的身份聯接到數據庫 "postgres". postgres=#?create table student (id int ,name char(20)); CREATE TABLE windows下的安裝和使用 (1)安裝 安裝包可以在http://www.postgresql.org/download/下載。 下載結果為:postgresql-9.1.2-1-windows.exe 安裝之后,把安裝路徑下的bin目錄(例如C:\Program Files\PostgreSQL\9.1\bin)加到path環境變量中,然后打開cmd命令行。 (2)連接和使用 輸入psql?huangwei?postgres前者是數據庫名稱后者是用戶名) 如下: C:\Documents and Settings\Administrator>psql huangwei postgres psql (9.1.1) 輸入 "help" 來獲取幫助信息. huangwei=#?help 您正在使用psql, 這是一種用于訪問PostgreSQL的命令行界面 鍵入: \copyright 顯示發行條款 \h 顯示 SQL 命令的說明 \? 顯示 pgsql 命令的說明 \g 或者以分號(;)結尾以執行查詢 \q 退出 然后就可以進行sql操作了,如創建表: huangwei=#?create table t1(id int ,name char(30)); CREATE TABLE 如何退出psql 呢? huangwei=#?\q 基本使用: (1)查看當前模式下的所有表 范例:查看模式public下的所有表:

select tablename from pg_tables where schemaname='public';

(2)創建用戶:

create user hw with password 'root' SUPERUSER CREATEDB CREATEROLE REPLICATION

?? VALID UNTIL 'infinity';

轉載于:https://blog.51cto.com/huangkunlun520/792054

總結

以上是生活随笔為你收集整理的postgreSQL入门01-安装的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。