docker启动oracle
1、切换到root账号下,如果是普通账号,下面操作指令前面加sudo
2.搜索oracle镜像
docker search oracle
3.下载oracle镜像
docker pull registry.cn-hangzhou.aliyuncs.com/qida/oracle-xe-11g
4.查看镜像
docker images
imgdocker images registry.cn-hangzhou.aliyuncs.com/qida/oracle-xe-11g
5.从下载的镜像创建并启动容器
docker run -d -p 1521:1521 --name oracle registry.cn-hangzhou.aliyuncs.com/qida/oracle-xe-11g
这里把新建的容器命名为oracle,并且是做了-d的端口映射的。
6.查看当前运行的容器
imgdocker ps
7.进入已经启动的Oracle的容器
docker exec -it oracle bash
img8.加载环境变量
source /home/oracle/.bash_profile
9.进入sqlplus
imgsqlplus /nolog
10.使用sysdba角色登录sqlplus
imgconn sys/oracle as sysdba
11.查看当前实例下的数据库
select name from v$database;
img
12.查看有多少个数据表
img13.退出sqlplus
exit
14.退出容器
exit 或Ctrl+D
15.重新进入已经运行的oracle容器,重新执行下面指令
docker exec -it oracle11 bash
16.如果容器停用了,则重新启动, 用你实际的容器ID代替下面的container_ID
docker start container_ID
17.停用正在运行的容器
docker stop container_ID
-
解锁scott用户
SQL> alter user scott account unlock; User altered. SQL> commit; Commit complete. SQL> conn scott/tiger ERROR: ORA-28001: the password has expired Changing password for scott New password: Retype new password: Password changed Connected. SQL>
-
新增用户
sql> create user test identified by test; sql> grant connect,resource,dba to test;
注意用docker安装的oracle实例名为:helowin,就是下图的sid。
-
使用dataGrip连接oracle数据库
数据库安装完成后,使用默认的sid为helowin,端口为1521,scott/tiger即可连接
image.png