本文介绍了Oracle Database12c ORA 01918和连接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了Oracle 12c,但在创建和使用第一个数据库时遇到了问题.我运行SQL Developer并使用"hr"用户,但它一直告诉我该帐户已锁定.我搜索了stackoverflow的答案和官方文档,并尝试使用以下方法对其进行解锁:

I have installed the Oracle 12c and I have problems creating my first database and using it.I run SQL Developer and use "hr" user but it keeps telling me that the account is locked. I searched into stackoverflow answers and official doc and tried to unlock it with:

ALTER USER HR IDENTIFIED BY password ACCOUNT UNLOCK;

,但没有成功.我收到错误ORA01918,表示该用户不存在.

but with no success. I got error ORA01918, meaning that user does not exist.

然后我尝试使用在安装中创建的用户(SYS为SYSDBA),但随后它说用户/密码不正确.我非常确定我已经在Windows 8.1 x64系统上正确安装了Oracle 12c.

I tried then to use the user created at the installation (SYS as SYSDBA)but then it says that the user/password is incorrect. I am pretty sure that I have installed Oracle 12c correctly on my system, which is Windows 8.1 x64.

我该怎么办?请帮我.

What should I do? Please help me.

我不明白的另一件事是,术语数据库"是否等同于MySQL的"Schema"? 连接"是连接到特定的数据库,是吗?谢谢.

Other thing I do not understand is wether or not the term "database" is equivalent to MySQL's "Schema"? The "connection" is to connect to a specific database, yes?Thank you.

推荐答案

您如何配置数据库?您是否检查了Pluggable database的选项?如果是,请确保您登录的是PDB而不是CDB.

How did you configure your database? Did you check the option for Pluggable database? If yes, please make sure you login to PDB and not CDB.

请阅读 Oracle 12c后期安装强制性步骤 .

默认情况下,pre-installed用户(例如SCOTTHR等)位于container database中,而不位于pluggable database中.

By default, pre-installed users like SCOTT, HR etc. resides in container database and not in pluggable database.

tnsnames.ora

编辑您的tnsnames.ora文件以添加PDB详细信息.例如,

Edit your tnsnames.ora file to add the PDB details. For example,

PDBORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdborcl)
    )
  )

打开所有PDB

要在登录后立即打开所有/特定的PDB,请在CDB中创建一个启动后系统级触发器.

To open all/specific PDBs immediately after logon, create a AFTER STARTUP system level trigger in CDB.

因此,从CDB开始就不会打开PDB.我们来看一下:

Since, the PDBs are not open through a CDB start. Let’s see :

SHUTDOWN IMMEDIATE;
STARTUP;

SQL> SELECT name, open_mode FROM v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDBP6                          MOUNTED

因此,为了使所有PDB自动打开,请执行以下操作:

So, in order to have all the PDBs automatically open, do this :

执行" SQLPLUS / AS SYSDBA ",然后执行:

Do, "SQLPLUS / AS SYSDBA", and then execute :

CREATE OR REPLACE TRIGGER open_pdbs
  AFTER STARTUP ON DATABASE
BEGIN
   EXECUTE IMMEDIATE 'ALTER PLUGGABLE DATABASE ALL OPEN';
END open_pdbs;
/

它将在CDB中创建启动后的系统级触发器.

It creates a after startup system level trigger in CDB.

SQLPLUS/AS SYSDBA

最常见的误解是关于"SQLPLUS/AS SYSDBA"的用法.

The most common misunderstanding is about "SQLPLUS / AS SYSDBA" usage.

由于我们已经选中了创建单个 CDB 的选项,因此"SQLPLUS/AS SYSDBA"命令将始终登录CDB.通常,开发人员通常在以SYSDBA身份登录后直接解锁"SCOTT"帐户.但这是窍门:

Since we have checked the option to create a single CDB, the "SQLPLUS / AS SYSDBA" command will always log into CDB. Usually developers used to unlock the "SCOTT" account directly after logging as SYSDBA. But here is the trick :

"SCOTT"和其他示例模式在PDB中,而不在CDB中.因此,您需要以sysdba身份登录到PDB.

"SCOTT" and other sample schemas are in the PDB and not in the CDB. So, you need to login as sysdba into PDB.

sqlplus SYS/password@PDBORCL AS SYSDBA

SQL> ALTER USER scott ACCOUNT UNLOCK IDENTIFIED BY tiger;

sqlplus scott/tiger@pdborcl

SQL> show user;
USER is "SCOTT"

这篇关于Oracle Database12c ORA 01918和连接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 00:42