Oracle 19c无法创建用户及测试连接问题求助(附操作步骤图片)
Hey there, let’s troubleshoot your Oracle 19c user creation and connection issues together. Based on common pain points in 19c, here’s a step-by-step breakdown to get to the bottom of this:
To create a user, you need the CREATE USER privilege. If you’re working in a Container Database (CDB), you might need additional container-specific permissions. First, check what privileges you have:
SELECT * FROM SESSION_PRIVS WHERE PRIVILEGE LIKE '%CREATE USER%';
- If you don’t see
CREATE USERin the results, log in as a user with SYSDBA privileges (like SYS) and grant the necessary permissions:GRANT CREATE USER TO your_current_username; -- For cross-container access in CDBs, add CONTAINER=ALL GRANT CREATE USER TO your_current_username CONTAINER=ALL;
Oracle 19c defaults to a CDB architecture, and this trips up a lot of folks:
- If you’re in the root container (
CDB$ROOT), you can only create common users which require aC##prefix:CREATE USER C##testuser IDENTIFIED BY your_secure_password; - For regular (local) users, you need to switch to a Pluggable Database (PDB) first. Start by listing available PDBs:
SELECT NAME, OPEN_MODE FROM V$PDBS; - Switch to your target PDB (replace
PDBORCLwith your actual PDB name):ALTER SESSION SET CONTAINER=PDBORCL; - Now you can create a regular user without the
C##prefix:CREATE USER testuser IDENTIFIED BY your_secure_password;
Oracle 19c enforces default password complexity rules that might block user creation. Let’s check the current policy:
SELECT * FROM DBA_PROFILES WHERE PROFILE='DEFAULT' AND RESOURCE_NAME LIKE '%PASSWORD%';
- If your password doesn’t meet the requirements, either:
- Choose a password that matches the complexity rules (e.g., mix of letters, numbers, special characters), or
- Temporarily adjust the profile (not recommended for production environments):
ALTER PROFILE DEFAULT LIMIT PASSWORD_VERIFY_FUNCTION NULL; ALTER PROFILE DEFAULT LIMIT PASSWORD_REUSE_MAX UNLIMITED;
Even if you create the user successfully, you might still hit connection issues. Try these checks:
- Grant the CREATE SESSION privilege: Users can’t log in without this. Run:
GRANT CREATE SESSION TO testuser; - Check the Oracle Listener: Make sure the listener service is running. Open a command prompt and run:
If it’s stopped, start it withlsnrctl statuslsnrctl start. - Validate Your Connection String: For PDB connections, you need to specify the PDB service name in your connection string. Example:
If using a TNS alias, double-check yoursqlplus testuser/your_password@//localhost:1521/PDBORCLtnsnames.orafile to ensure it points to the correct PDB service. - Check if the User is Locked: Multiple failed login attempts can lock the user. Verify the status:
If locked, unlock the user with:SELECT USERNAME, ACCOUNT_STATUS FROM DBA_USERS WHERE USERNAME='TESTUSER';ALTER USER testuser ACCOUNT UNLOCK;
If none of the above works, pay close attention to the exact error message and ORA-xxxx code you get when creating the user or testing the connection. Codes like ORA-01031 (insufficient privileges) or ORA-65096 (invalid common user name) will directly point to the root cause. Sharing these codes will help us zero in on the problem faster.
内容的提问来源于stack exchange,提问作者Parth

