docker安装db2数据库

拉取镜像

docker pull ibmoms/db2express-c

运行容器

[root@localhost zabbix]# docker run -it --network=host -p50000:50000 -e DB2INST1_PASSWORD=db2root-pwd -e LICENSE=accept ibmoms/db2express-c bash
Changing password for user db2inst1.
New password: Retype new password: passwd: all authentication tokens updated successfully.

-p 50000:50000 允许远程的客户端可以从50000 端口连接到数据库实例.
通过指定 -e DB2INST1_PASSWORD=db2root-pwd 参数, 你可以为缺省的Db2实例用户db2inst1设置密码.注意:这里“DB2INST1”是用户名,而“db2root-pwd”是密码。
通过指定-e LICENSE=accept参数, 表示你接受了使用Db2软件的许可证协议.

切换用户

su - db2inst1 // 切换用户
db2start //启动DB2
db2sampl // 创建默认的数据库SAMPLE
[root@localhost /]# su - db2inst1
Last login: Wed May 20 21:57:28 UTC 2015
[db2inst1@localhost ~]$ db2start
SQL1063N  DB2START processing was successful.
[db2inst1@localhost ~]$ db2sampl 

  Creating database "SAMPLE"...
  Connecting to database "SAMPLE"...
  Creating tables and data in schema "DB2INST1"...
  Creating tables with XML columns and XML data in schema "DB2INST1"...

  'db2sampl' processing complete.


常用的DB2命令

db2 create db [dbname]   #创建数据库
db2 list db directory  # 列出所有数据库
db2 list active databases  # 列出所有激活的数据库
db2 get db cfg # 列出所有数据库配置

创建一个数据库

[db2inst1@localhost ~]$ db2 create db hbktest
DB20000I  The CREATE DATABASE command completed successfully.

使用客户端DbVisualizer工具进行连接,输入安装定义的账号密码,进行连接。“DB2INST1”是用户名,而“db2root-pwd”是密码。
在这里插入图片描述

[db2inst1@localhost ~]$ db2 list db directory

 System Database Directory

 Number of entries in the directory = 2

Database 1 entry:

 Database alias                       = HBKTEST
 Database name                        = HBKTEST
 Local database directory             = /home/db2inst1
 Database release level               = 10.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

Database 2 entry:

 Database alias                       = SAMPLE
 Database name                        = SAMPLE
 Local database directory             = /home/db2inst1
 Database release level               = 10.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

[db2inst1@localhost ~]$ db2 list active databases

                           Active Databases

Database name                              = HBKTEST
Applications connected currently           = 1
Database path                              = /home/db2inst1/db2inst1/NODE0000/SQL00002/MEMBER0000/

安装好db2数据库,然后是结合DB2的语法,慢慢去掌握,工具也花哨的,平时经常接触mysqlyog,oracle developer,初次接触DbVisualizer,还挺好用的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黄宝康

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值