最近在给同学弄毕业设计的数据库,因为oracle在个人电脑上极不稳定,所以他的电脑数据库崩溃了,这时候我就在docker上为他拉了一个oracle,解决了问题。
docker的安装共有以下几步,实测没问题,直接搬去永久可以了,希望可以帮到你。
1、拉取镜像
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
2、查看镜像
docker images
3、创建容器
docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
##### 4、进入容器
docker exec -it oracle11g bash
5、切换到oracle数据库的root 用户下
(对环境变量的编辑配置需要操作权限)
su root
密码:helowin
6、进入配置文件中进行修改
vi /etc/profile
添加内容:
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH
注意:按i进入编辑模式,输入上述命令后,按ESC键退出编辑模式,再输入:wq保存退出
如图所示:
7.重启配置文件服务
source /etc/profile
8、创建软链接
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
9、切换到oracle用户,修改oracle的相关账号密码
su oracle
10、登录sqlplus–修改sys、system用户密码–创建用户
sqlplus /nolog
conn /as sysdba
alter user system identified by system;(修改密码为system)
alter user sys identified by sys;(修改密码为sys)
创建用户
create user test identified by test;
并给用户赋予权限
grant connect,resource,dba to test;
接下来,你就可以通过plsql、sqldeveloper等软件进行连接了
如图:
以上!希望能够帮到你。