文章目录
- 症状
- 分析
- 解决办法
- 欢迎加下方我的微信👇,拉你入学习群
我们在登录Oracle数据库时可能会遇到ORA-01017错误,这里分析原因并提供解决办法。
点击试看博主的专著《MySQL 8.0运维与优化》(清华大学出版社)
症状
图像工具的错误提示类似下图:
或者
oracle@yaoyuan ~$ sqlplus yao/yaoyuan2
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Mar 1 17:48:24 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
ERROR:
ORA-01017: invalid username/password; logon denied
分析
这种情况不是密码过期,如果是密码过期,会要求输入密码:
oracle@yaoyuan ~$ sqlplus yao/yaoyuan
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Mar 1 17:47:54 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
ERROR:
ORA-28001: the password has expired
Changing password for yao
New password:
Retype new password:
Password changed
也不会是权限不够,如果是权限不够,会有下面的报错:
oracle@yaoyuan ~$ sqlplus yao/yaoyuan
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Mar 1 17:46:02 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
ERROR:
ORA-01045: user YAO lacks CREATE SESSION privilege; logon denied
这种情况就是密码错误:
oracle@yaoyuan ~$ sqlplus yao/yaoyuan2
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Mar 1 17:48:24 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
ERROR:
ORA-01017: invalid username/password; logon denied
解决办法
如果知道密码输入正确的密码即可:
oracle@yaoyuan ~$ sqlplus yao/yaoyuan
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Mar 1 18:06:06 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Last Successful login time: Wed Mar 01 2023 17:48:18 +08:00
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL>
如果不知道密码可以使用sys用户将普通用户的密码重置:
SQL> alter user yao identified by yaoyuan;
User altered.
然后再使用修改后的密码登录即可。