標籤:密碼 examples page null gre 預設 prim group 地址
作業系統:CentOS6.9_x64
DB2安裝檔案: db2_v101_linuxx64_expc.tar.gz
安裝資料庫
tar zxvf db2_v101_linuxx64_expc.tar.gzcd expc/./db2_install
選擇預設安裝路徑 : yes
設定資料庫
建立3個使用者組
groupadd -g 901 db2iadm1groupadd -g 902 db2fadm1groupadd -g 903 db2dadm1
建立3個使用者
useradd -g db2iadm1 -u 101 -d /home/db2inst1 -m db2inst1useradd -g db2fadm1 -u 102 -d /home/db2fenc1 -m db2fenc1useradd -g db2dadm1 -u 103 -d /home/db2dasusr1 -m db2dasusr1
添加3個使用者密碼
passwd db2inst1passwd db2fenc1passwd db2dasusr1
檢查使用者組和使用者是否建立成功
cat /etc/group | grep db2cat /etc/passwd | grep db2
建立執行個體
cd /opt/ibm/db2/V10.1/instance./dascrt -u db2dasusr1./db2icrt -a server -u db2fenc1 db2inst1
配置db2自啟動
cd /opt/ibm/db2/V10.1/instance./db2iauto -on db2inst1
配置db2網路服務連接埠
su - db2inst1 db2 update dbm cfg using SVCENAME 50000
修改DB2串連方式為TCP/IP
db2set DB2COMM=TCPIP
使用資料庫
啟動資料庫
su - db2inst1 db2start
建立資料庫
db2 create db testdb using codeset UTF-8 territory CN pagesize 8192
串連到資料庫:
db2 connect to testdb
顯示串連
db2 list applications
sql測試代碼:
create table tb1( id integer not null primary key,username varchar(200),password varchar(200));insert into tb1(id,username,password) values(188,‘stevenjohn‘,‘stevenanthony‘) ;select * from tb1;drop table tb1;
python測試代碼:
https://github.com/mike-zhang/pyExamples/blob/master/databaseRelate/db2Opt/db2Test1.py
好,就這些了,希望對你有協助。
本文github地址:
https://github.com/mike-zhang/mikeBlogEssays/blob/master/2017/20170706_cenos6.9下安裝db2.rst
歡迎補充
CentOS 6.9 下安裝DB2