拉取镜像
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
运行容器
docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
进入容器
docker exec -it oracle11g /bin/bash
修改密码
[root@centos7 ~]# docker exec -it oracle11g /bin/bash
[oracle@79a99e56edfd /]$ su root
Password: helowin
[root@79a99e56edfd /]# su - oracle
[oracle@79a99e56edfd ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sat Oct 29 14:51:20 2022
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> SELECT * FROM ALL_USERS;
SQL> alter user SYSTEM account unlock;
User altered.
SQL> alter user SYSTEM identified by system;
User altered.
SQL> alter user scott account unlock;
User altered.
SQL> alter user scott identified by scott;
User altered.
SQL>
编辑 /etc/profile 文件配置ORACLE环境变量
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
创建软连接
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
source /etc/profile
登录sqlplus
sqlplus /nolog
conn /as sysdba
sql
alter user 用户名 account unlock; --------- 解除锁定(必须带“;”号,注意用英文字符)
alter user 用户名 identified by 密码; -------------修改密码
查看某个用户是否被锁:
select LOCK_DATE,username from dba_users where username='用户名';
LOCK_DATE为空说明没有锁定,非空为锁定。
Oracle sys密码的重置方法:
在系统运行中输入:sqlplus/nolog
在命令窗口分别执行:conn/as sysdba
//查询所有用户
SELECT * FROM ALL_USERS;
//查询用户下的所有表
select * from all_tables where owner='用户名';
//删除表
drop table 表名;