進入容器
docker ps ## 查看容器的id號,復制一下 docker exec -it xxxxxxxx /bin/bash ## xxxxxxx就是上一部查看的id號
查看oracle狀態,修改system用戶密碼:
source ~/.bash_profile ## 加載一下用戶環境變量,進入容器后,自動是oracle用戶 sqlplus /nolog ## 使用sqlplus 工具,進去命令行 SQL> connect /as sysdba ## 使用sysdba 連接oracle,最大權限,os認證,只能在本機上登陸使用。 SQL> select status from v$instance; ## 查看oracle現在的狀態 ,狀態為 OPEN 則正常,表示已開啟狀態。 SQL> alter user system identified by oracle; ## 修改用戶 system 的密碼為 oracle ,可以自定義
然后就是創建表空間,創建用戶,並授權:
SQL> select name from v$tempfile; ## 查詢臨時表空間的路徑 ## 下面這句,創建表空間,名:tets ,數據文件路徑復制臨時表空間數據文件路徑然后改一下文件名就行了,大小:1G, 自動增長:50M 。 參數根據自己的需求自行修改 SQL> create tablespace test datafile '/home/oracle/app/oracle/oradata/helowin/tets02.dbf' size 1G reuse autoextend on next 50M maxsize unlimited default storage(initial 128k next 128k minextents 2 maxextents unlimited); SQL> select tablespace_name from dba_tablespaces ## 查看所有表空間,看看是否有剛才創建的 SQL> create user test01 identified by testpasswd default tablespace TEST temporary tablespace TEMP; ## 創建用戶,test01,密碼:testpass,設置默認表空間為剛才創建的 test, 臨時表空間設為默認的 TEMP。 SQL> select username from dba_users ## 查看用戶名,可以看到是否有剛才我們創建的用戶名 SQL> grant connect,dba,exp_full_database,imp_full_database to test01 with admin option; ## 授權用戶 test01,擁有連接,管理員,導入,導出權限,並可以傳遞權限。(根據需求自己定義權限)
如果用pl/sql develop ,請用system登錄, system默默密碼:oracle
select name from v$tempfile; ## 查詢臨時表空間的路徑
#創建表空間 create tablespace lygj datafile '/home/oracle/app/oracle/oradata/helowin/temp02.dbf' size 100m autoextend on next 10m; #創建用戶,並選擇表空間 create user lygj identified by 123456 default tablespace lygj; #授權登錄 grant dba to lygj;