• How to create new user for ORACLE 19c (CDB & PDB)


    ORACLE 19c新建用户

    数据据库、用户、CDB与PDB之间的关系

    通常在CDB上建立的用户是common user,新建用户名前要加C##。在PDB上创建的用户是local user。

     

    在CDB上创建用户

    1.Guarante this action under the CDB enviroment.

    [oracle@MaxwellDBA ~]$ sqlplus system/system as sysdba

    SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jun 29 10:12:29 2022
    Version 19.3.0.0.0

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


    Connected to:
    Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
    Version 19.3.0.0.0

    SQL> select name,cdb from v$database;

    NAME      CDB
    --------- ---
    ORCLCDB   YES

    2. Create New User

    SQL> create user C##test identified by testpass;

    User created.

    3.setting authority

    SQL> grant dba,connect,resource,create view to C##test;

    Grant succeeded.

    SQL> grant create session to C##test;

    Grant succeeded.

    SQL> grant select any table to C##test;

    Grant succeeded.

    SQL> grant update any table to C##test;

    Grant succeeded.

    SQL> grant insert any table to C##test;

    Grant succeeded.

    SQL> grant delete any table to C##test;

    Grant succeeded.

    4. Drop user

    SQL> drop user C##test cascade;

    User dropped.

    SQL> 

    Create new user on PDB

    1. check the PDB name
    1. SQL> select pdb_id,pdb_name,dbid,status,creation_scn from dba_pdbs;
    2. PDB_ID
    3. ----------
    4. PDB_NAME
    5. --------------------------------------------------------------------------------
    6. DBID STATUS CREATION_SCN
    7. ---------- ---------- ------------
    8. 3
    9. ORCLPDB1
    10. 634705280 NORMAL 2156143
    11. 2
    12. PDB$SEED
    13. 1473614105 NORMAL 2014329
    14. PDB_ID
    15. ----------
    16. PDB_NAME
    17. --------------------------------------------------------------------------------
    18. DBID STATUS CREATION_SCN
    19. ---------- ---------- ------------
    20. SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;
    21. CON_ID DBID
    22. ---------- ----------
    23. NAME
    24. --------------------------------------------------------------------------------
    25. OPEN_MODE
    26. ----------
    27. 2 1473614105
    28. PDB$SEED
    29. READ ONLY
    30. 3 634705280
    31. ORCLPDB1
    32. READ WRITE
    33. CON_ID DBID
    34. ---------- ----------
    35. NAME
    36. --------------------------------------------------------------------------------
    37. OPEN_MODE
    38. ----------

    Local User PDB Name is ORCLPDB1

    Enter into the PDB enviroment 

    SQL> alter session set container=ORCLPDB1;

    1. SQL> alter session set container=ORCLPDB1
    2. 2 ;
    3. Session altered.

    New User

    1. SQL> create user test2 identified by test2pass;
    2. User created.
    3. SQL>

    Setting authority

    1. grant dba,connect,resource,create view to test2;
    2. grant select any table to test2;
    3. grant update any table to test2;
    4. grant insert any table to test2;
    5. grant delete any table to test2;
    6. grant create session to test2;

    Setting the TNS

    If not setting the TNS, it will be failed . error message is user/password error , due to the user on CDB defaultly. need to change the file tnsname.ora on remote linux oracle path network/admin(/opt/oracle/product/19c/dbhome_1/network/admin) 

    1. # tnsnames.ora Network Configuration File: /opt/oracle/product/19c/dbhome_1/network/admin/tnsnames.ora
    2. # Generated by Oracle configuration tools.
    3. ORCLCDB =
    4. (DESCRIPTION =
    5. (ADDRESS = (PROTOCOL = TCP)(HOST = MaxwellDBA)(PORT = 1521))
    6. (CONNECT_DATA =
    7. (SERVER = DEDICATED)
    8. (SERVICE_NAME = ORCLCDB)
    9. )
    10. )
    11. LISTENER_ORCLCDB =
    12. (ADDRESS = (PROTOCOL = TCP)(HOST = MaxwellDBA)(PORT = 1521))
    13. ORCLPDB1 =
    14. (DESCRIPTION =
    15. (ADDRESS = (PROTOCOL = TCP)(HOST = MaxwellDBA)(PORT = 1521))
    16. (CONNECT_DATA =
    17. (SERVER = DEDICATED)
    18. (SERVICE_NAME = ORCLPDB1)
    19. )
    20. )
    21. LISTENER_ORCLPDB1 =
    22. (ADDRESS = (PROTOCOL = TCP)(HOST = MaxwellDBA)(PORT = 1521))

     Login user:

     

  • 相关阅读:
    集群搭建(1)
    《计算机体系结构量化研究方法》1.8 性能的测量、报告和汇总
    第三次工业革命(六)
    2024年华为OD机试真题-抢7游戏-C++-OD统一考试(C卷D卷)
    14.HTML和CSS 02
    node对接微信支付,微信返回失败
    【OpenCV 例程 300篇】243. 特征检测之 FAST 算法
    云计算+区块链,企业数字化转型的混合强劲动力
    Python的Numpy库的ndarray对象常用构造方法及初始化方法
    js逆向-逆向基础
  • 原文地址:https://blog.csdn.net/u011868279/article/details/125515342