ChatGPT解决这个技术问题 Extra ChatGPT

Changing password with Oracle SQL Developer

Many of my users do not use SQLPlus. I cannot give them alter user. We expire passwords every 60 days.

I can't get the SQLPlus command "password" to work in SQL developer.

When I hit run, I get an invalid command error When I hit run script, nothing happens.

I don't want to write them a package to change their passwords since we have a lot of databases. Do I have a better option?

You cannont change an expired password in SQL Developer via SQL command. It is not supported in the JDBC stack. You need the OCI libraries for this. SQL developer has an option to reset and expired password via the OCI stack if it has been correctly installed. See my answer for full details.
You can do this with SQL Developer 4.1.0.17. See my answer below.

N
Nicolás Alarcón Rapela

The correct syntax for updating the password using SQL Developer is:

alter user user_name identified by new_password replace old_password ;

You can check more options for this command here: ALTER USER-Oracle DOCS


Also, you may need to wrap the password(s) in double quotes to escape any special characters in the password. For example, alter user __user_name__ identified by "newp@ss!!!" replace "oldp@ss!!!" More info at asktom.oracle.com/pls/asktom/…
If your pwd has expired then good luck logging in to run this. Answers A question, but not THE question.
So I just ran this. For future readers. You an fix another account (if you are a "super" with privs account). But you cannot fix YOURSELF with this syntax IF YOU(RSELF) has already expired. Lesson learned! Heed the warnings! Thanks A.M. I am running Sql Developer ( Version 19.4.0.354) against Oracle 18c .. FYI.
You need to be admin to run this command, cannot update the user self password. I.e. user: sys as SYSDBA . Check docs.oracle.com/database/121/ADMQS/… .
N
Nicolás Alarcón Rapela

In an SQL worksheet:

Type in "password" (without the quotes)

Highlight, hit CTRL+ENTER.

Password change screen comes up.


You can also do "password someusername"
I suppose you mean the "Run statement" action. The default short-cut seems to be Ctrl+Enter.
C
Community

SQL Developer has a built-in reset password option that may work for your situation. It requires adding Oracle Instant Client to the workstation as well. When instant client is in the path when SQL developer launches you will get the following option enabled:

https://i.stack.imgur.com/pR4FF.png

Oracle Instant Client does not need admin privileges to install, just the ability to write to a directory and add that directory to the users path. Most users have the privileges to do this.

Recap: In order to use Reset Password on Oracle SQL Developer:

You must unpack the Oracle Instant Client in a directory You must add the Oracle Instant Client directory to the users path You must then restart Oracle SQL Developer

At this point you can right click a data source and reset your password.

See http://www.thatjeffsmith.com/archive/2012/11/resetting-your-oracle-user-password-with-sql-developer/ for a complete walk-through

Also see the comment in the oracle docs: http://docs.oracle.com/cd/E35137_01/appdev.32/e35117/dialogs.htm#RPTUG41808

An alternative configuration to have SQL Developer (tested on version 4.0.1) recognize and use the Instant Client on OS X is:

Set path to Instant Client in Preferences -> Database -> Advanced -> Use Oracle Client Verify the Instance Client can be loaded succesfully using the Configure... -> Test... options from within the preferences dialog (OS X) Refer to this question to resolve issues related to DYLD_LIBRARY_PATH environment variable. I used the following command and then restarted SQL Developer to pick up the change: $ launchctl setenv DYLD_LIBRARY_PATH /path/to/oracle/instantclient_11_2


Not available for all users 80(
hmmm, doesn't seem to work for me. I wonder if updating the PATH is really all you have to do, on a Mac.
I use a mac an home, but a windows pc at work. We are switching to macs soon.. If I find the details I will post them.
Google is very helpful :-) with it I found: oracle.com/technetwork/topics/linuxx86-64soft-092277.html which may go stale. To google it again use goo.gl/kU5ZdM
Thank you, it worked on Windows 7 64bit. I did have to go through an extra step though (which is the same as the first step on OS X config above), otherwise the 'reset password' option would remain grayed out. 4. Set path to Instant Client in Preferences -> Database -> Advanced -> Use Oracle Client
d
dpbradley

Your users can still change their passwords by "alter user onlyTheirUserName identified by newpassword". They do not have to have the ALTER USER privilege to change their own password.


J
Jon Heller

Depending on the admin settings, you may have to specify your old password using the REPLACE option

alter user <username> identified by <newpassword> replace <oldpassword> 

can new password and oldpassword be same ?
This answer is wrong. newpassword and oldpassword are transposed. Use stackoverflow.com/a/10809140/643483 instead
@AaronKurtzhals The answer you reference says the same thing that my answer does. Reference the oracle docs here: docs.oracle.com/cd/B19306_01/server.102/b14200/…
The main thing to be added (which has been done by @pgs in his answer on this same question) is that you may need to put quotes around the passwords if they contain special characters.
B
Brad Bruce

To make it a little clear :

If the username: abcdef and the old password : a123b456, new password: m987n654

alter user abcdef identified by m987n654 replace a123b456;


S
Saad A

I realise that there are many answers, but I found a solution that may be helpful to some. I ran into the same problem, I am running oracle sql develop on my local computer and I have a bunch of users. I happen to remember the password for one of my users and I used it to reset the password of other users.

Steps:

connect to a database using a valid user and password, in my case all my users expired except "system" and I remember that password find the "Other_users" node within the tree as the image below displays

https://i.stack.imgur.com/MZg2Y.png

3.within the "Other_users" tree find your users that you would like to reset password of and right click the note and select "Edit Users"

https://i.stack.imgur.com/3YV9Q.png

4.fill out the new password in edit user dialog and click "Apply". Make sure that you have unchecked "Password expired (user must change next login)".

https://i.stack.imgur.com/hYLLD.png

And that worked for me, It is not as good as other solution because you need to be able to login to at least one account but it does work.


D
Dominik Honnef

I confirmed this works in SQL Developer 3.0.04. Our passwords are required to have a special character, so the double-quoted string is needed in our case. Of course, this only works if the password has not already expired and you are currently logged in.

ALTER USER MYUSERID
IDENTIFIED BY "new#password"
REPLACE "old#password"

This answer is wrong. newpassword and oldpassword are transposed. Use stackoverflow.com/a/10809140/643483 instead
L
Leo

Try this solution if the Reset Password option (of SQL Developer) did not work:

Step 1: Open Run SQL Command Line (from the start menu, which comes with SQL Developer installation package)

Step 2: Run the following commands:

https://i.stack.imgur.com/uxS1L.png

Note: If password has already expired, Changing password for <user> option will automatically come.


a
aizaz

The built-in reset password option may not work for user. In this case the password can be reset using following SQL statement:

ALTER user "user" identified by "NewPassword" replace "OldPassword";

S
Suchitra Phadke

There is another way to reset the password through command prompt ...

1) Go to the Oracle Database Folder ( In my case Oracle Database 11g Express Edition) in the START MENU.

2) Within that folder click "Run SQL Commandline"

Oracle Database Folder image

3) Type "connect username/password" (your username and old password without the quotation marks)

4) The message displayed is ...

ERROR: ORA-28001: the password has expired

Changing password for hr

--> New password:

Enter Username, Password image

5) Type the new password

6) Retype the new password

7) Message displayed is ...

Password changed Connected.

SQL>

8) GO TO Sql developer --> type the new password --> connected


While the OP is still active, 5 years after the question was asked, the answer may no longer be relevant.
@Strawberry if it answers the question, why not?!!
佚名

you can find the user in DBA_USERS table like

SELECT profile
FROM dba_users
WHERE username = 'MacsP'

Now go to the sys/system (administrator) and use query

ALTER USER PRATEEK
IDENTIFIED BY "new_password"
REPLACE "old_password"

To verify the account status just go through

SELECT * FROM DBA_USERS.

and you can see status of your user.


F
Fuzzy Analysis

You can now do this in SQL Developer 4.1.0.17, no PL/SQL required, assuming you have another account that has administrative privileges:

Create a connection to the database in SQL Developer 4.1.0.17 with an alternative administrative user Expand the "Other Users" section once connected, and right-click the user whose password has expired. Choose "Edit User". Uncheck the "Password Expired..." checkbox, type in a new password for the user, and hit "Save". Job done! You can test by connecting with the user whose password had expired, to confirm it is now valid again.


S
Sorokin Andrey

One note for people who might not have the set password for sysdba or sys and regularly use a third party client. Here's some info about logging into command line sqlplus without a password that helped me. I am using fedora 21 by the way.

locate sqlplus

In my case, sqlplus is located here:

/u01/app/oracle/product/11.2.0/xe/config/scripts/sqlplus.sh

Now run

cd /u01/app/oracle/product/11.2.0/xe/config/scripts
./sqlplus.sh / as sysdba

Now you need to connect to database with your old credentials. You can find Oracle provided template in your output:

Use "connect username/password@XE" to connect to the database.

In my case I have user "oracle" with password "oracle" so my input looks like

connect oracle/oracle@XE

Done. Now type your new password twice. Then if you don't want your password to expire anymore you could run

ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;

M
M.Hassan

I use version 21.2.0.187 (released on july 2021).

There is a reset button that enable you to reset password to a new password as shown in the next figures. you can reach it by right click mouse on the connection.

I rest the password, then login with the new password.

https://i.stack.imgur.com/0Ko76.png