1

Mac OS 和 docker 从 oracledb 控制台,我无法以 sys 身份连接,密码我在 oracle 中输入,但没有成功

SQL> connect sys as sysdba;
Enter password: 
ERROR:
ORA-12547: TNS:lost contact

我是怎么走到这一步的……

    docker pull absolutapps/oracle-12c-ee
    docker run -d --name oracle-12cR1-ee --privileged absolutapps/oracle-12c-ee
    docker logs -f oracle-12cR1-ee

最后我得到

PL/SQL procedure successfully completed.

Please login to http://<ip_address>:8080/em to use enterprise manager
User: sys; Password oracle; Sysdba: true
Fixing permissions...
Running init scripts...
Init scripts in /oracle.init.d/: Ignoring /oracle.init.d/*

Done with scripts we are ready to go

我运行的下一个命令是

docker exec -it 28b0f34f7a81 bash -c "source /home/oracle/.bashrc; sqlplus /nolog"

SQL*Plus: Release 12.1.0.2.0 Production on Fri Jun 28 23:08:41 2019


Copyright (c) 1982, 2014, Oracle.  All rights reserved.

SQL> connect sys as sysdba;
Enter password: 
ERROR:
ORA-12547: TNS:lost contact

在这一点上,我被困住了......

以前想过或看过这个吗?

4

1 回答 1

4

查看您正在使用的该图像的源代码,我能够看到它们正在使用gosu oracle sqlplus提升的权限连接到数据库,因此我在我的环境中尝试了这个,并且似乎完全适合您的需要:

docker exec -it oracle-12cR1-ee sh -c 'gosu oracle sqlplus "sys as sysdba"'

得到..

SQL*Plus: Release 12.1.0.2.0 Production on Sat Jun 29 00:33:12 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Enter password: 

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> 

然后能够(例如):

SQL> SELECT USERNAME from SYS.ALL_USERS;

享受!;)


编辑:

使用 justsqlplus / as sysdba也可以,所以它是:

docker exec -it oracle-12cR1-ee sh -c 'gosu oracle sqlplus / as sysdba'
于 2019-06-29T00:37:09.430 回答