Linux系統中PostgreSql下載及安裝基本知識

來源:互聯網
上載者:User

Linux系統中PostgreSql下載及安裝基本知識學習:

【ユーザー追加】
[root@localhost ~]# useradd postgres
[root@localhost ~]# passwd postgres

【PostgreSQLダウンロード】
[root@localhost ~]# cd /usr/local/src
[root@localhost ~]# wget ftp://ftp.postgresql.org/pub/binary/v8.0.15/linux/rpms/RedHat/rhel3.0/postgresql-server-8.0.15-1PGDG.i386.rpm
[root@localhost ~]# wget ftp://ftp.postgresql.org/pub/binary/v8.0.15/linux/rpms/redhat/rhel3.0/postgresql-devel-8.0.15-1PGDG.i386.rpm
[root@localhost ~]# wget ftp://ftp.postgresql.org/pub/binary/v8.0.15/linux/rpms/redhat/rhel3.0/postgresql-libs-8.0.15-1PGDG.i386.rpm
[root@localhost ~]# wget ftp://ftp.postgresql.org/pub/binary/v8.0.15/linux/rpms/redhat/rhel3.0/postgresql-8.0.15-1PGDG.i386.rpm

【PostgreSQLインストール】
[root@localhost ~]# rpm -ivh postgresql-*8.0.15-1PGDG.i386.rpm

【PostgreSQL起動】
[root@localhost ~]# /etc/rc.d/init.d/postgresql start                         

【PostgreSQL自動起動設定】
[root@localhost ~]# chkconfig postgresql on                                   
【PostgreSQL自動起動設定確認】
[root@localhost ~]# chkconfig --list postgresql                           
    postgresql 0:off 1:off 2:on 3:on 4:on 5:on 6:off                  ランレベル2~5のonを確認

【postgresユーザになる】
[root@localhost ~]# su - postgres

【PostgreSQLにCentOSユーザを追加(システムに登録済のユーザであること)】
-bash-2.05b$ createuser -AdPE centos
    CREATE USER

【データベースtestを作成】
-bash-2.05b$ createdb --encoding EUC_JP test
    CREATE DATABASE

【データベースtestdbを作成確認】
-bash-2.05b$ psql -l
             List of databases
       Name    |   Owner   | Encoding
    -----------+-----------+-----------
     template0 | postgres  | SQL_ASCII
     template1 | postgres  | SQL_ASCII
     test      | centos    | EUC_JP
    (3 rows)

【psqlツール起動】
-bash-2.05b$ psql test

【テーブルtestを作成】
-bash-2.05b$ create table test(num int, name varchar(50));
    CREATE TABLE
    test=> \d test ← テーブルtest作成確認
                Table "public.test"
     Column |         Type          | Modifiers
    --------+-----------------------+-----------
     num    | integer               |
     name   | character varying(50) |

【データ登録】
 test=> insert into test values(1,'山田太郎'); ← テーブルtestにデータを登録
    INSERT

【データ照會】
test=> select * from test;
         num |   name
         -----+-----------
        1 | 山田太郎
      (1 row)

【テーブル削除】
 test=> drop table test;
    DROP TABLE

【psqlツール停止】
 test=> \q

【データベース削除】
-bash-2.05b$ dropdb test
    DROP DATABASE
-bash-2.05b$ exit

【PostgreSQLユーザ削除】
[root@linux ~]# su - postgres
-bash-2.05b$ dropuser centos
    DROP USER
-bash-2.05b$ exit

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.