当前位置: 代码迷 >> 综合 >> docker 中安装oracle11g,并使用Navicat Premium 12进行远程连接
  详细解决方案

docker 中安装oracle11g,并使用Navicat Premium 12进行远程连接

热度:34   发布时间:2023-12-15 14:50:38.0

安装

docker 安装(省略)

在docker 中安装Oracle11G

  1. 步骤1:
    获取oracke11g镜像,等待镜像下载完成。
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

通过命令查看当前所有镜像,就可看到镜像 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

docker images
  1. 步骤2:
    创建容器
docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

通过命令查看镜像运行状态

docker ps -a 

看到以下的运行状态 Up 则表示镜像已经运行成功

registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g   "/bin/sh -c '/home/o鈥?  up 40 minutes ago      Up 40 minutes               0.0.0.0:1521->1521/tcp   oracle11g
  1. 交互方式进入Oracle11g的镜像中进行操作,此时注意,进入后当前的用户为 oracle
docker exec -it oracle11g bash
  1. 配置oracle 的环境变量,建议使用 ls 或者 ll 命令查看当前目录结构。
    用以下命令切换到root用户,密码是:helowin,此时,当前的角色为root。
 su root

使用命令操作以下文件,进入编辑模式编辑该文件。

vi /etc/profile

在该文件末尾添加以下配置后并 wq! 保存退出:

export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH
  1. 创建连接
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
  1. 切换到oracle 用户
su - oracle
  1. 登录 sqlplus
 sqlplus /nolog
 conn /as sysdba

此时看到提示:Connected. 说明成功

  1. 遵守最低权限原则,创建一个用户,并给此用户进行权限分配。
    由于平时使用的mysql账号密码默认都是root ,所以个人保持习惯使用账号和密码都是root,使用时注意分配的权限不宜过高。

修改系统用户

alter user sys identified by root;
alter user system identified by root;

创建账号:

create user root(此处的root为账号) identified by root (此处的root为密码);

授权

 grant create session to root;grant create table,unlimited tablespace to root;grant select any table to root;grant update any table ,drop any table ,insert any table to root;alter system set O7_DICTIONARY_ACCESSIBILITY=true scope=spfile;

将上面的命令执行完毕后打开 Navicat Premium 12,创建oracle的连接:
填写连接信息:

连接名 自定义的名称
连接类型 basic
主机名 xx.xx.xx.xxx (服务器的公网IP地址)
端口 默认为1521,若在步骤二创建容器时指定其他的端口,则在此与步骤二中指定的一致
服务名 默认为helowinXDB
用户名 为步骤八中创建的root
密码 为步骤八中创建的root
  相关解决方案