簡體   English   中英

如何在linux上使用包含@的密碼和sqlplus 18、19或21?

[英]How to use password containing @ with sqlplus 18, 19 or 21 on linux?

我的 ORACLE 帳戶帶有 at 符號 (@) 到密碼。

我使用的是 sqlplus 12,我可以使用以下語法處理這個特殊字符:

sqlplus 'USER/\"@PWD\"@SERVER:1521/BASE'

現在使用 sqlplus 19,這不再起作用了。 並且在多個操作系統(RHEL7 RHEL8 CentOS7)上經過多次測試(sqlplus v18 v19和v21),問題是一樣的。 我已經測試了很多逃生方法並在整個互聯網上搜索,但沒有找到任何有效的方法。

這個問題似乎特定於 @ 符號,我可以逃避一個! 以 \\ 為例。

編輯:我需要自動化這個,所以人機交互的解決方案不能解決我的問題。

您可以通過在sqlplus內部進行連接來解決此問題,順便說一下,如果您想將連接封裝在 shell 腳本中,這會更好。

讓我向您展示(Oracle 19c over Red Hat 7)

SQL> select version from v$instance ;

VERSION
-----------------
19.0.0.0.0

SQL> create user test identified by "Ora@xde1" ;

User created.

SQL> grant connect to test ;

Grant succeeded.

如果在命令行中連接,它不起作用

sqlplus test/"Ora@xde1"

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Sep 10 13:07:28 2021
Version 19.3.0.0.0

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

ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified

但是,如果你在里面連接,它確實有效

sqlplus /nolog

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Sep 10 13:08:05 2021
Version 19.3.0.0.0

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

SQL> conn test/"Ora@xde1"
Connected.
SQL> select 1 from dual ;

         1
----------
         1

根據@Roberto Hernandez 的回答,我使用他的解決方案進行了一些修改以在腳本內部工作,而無需交互輸入密碼:

sqlplus /nolog << EOF\\nconn /""@:1521/\\n@""

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM