gpt4 book ai didi

ruby-on-rails - Rails + Oracle + oracle_enchanced 适配器 : db:create asks for SYSTEM password?

转载 作者:行者123 更新时间:2023-12-04 05:35:59 25 4
gpt4 key购买 nike

我刚刚更新了一个 older post about Rails + Oracle DB并想知道为什么我的 rake db:create db:migrate向我询问 Oracle DB 的 SYS/SYSTEM 密码。我在 config/database.yml 配置的 Oracle 用户具有以下权限:

GRANT CREATE SESSION TO my-user;
GRANT ALTER SESSION TO my-user;
GRANT CREATE SEQUENCE TO my-user;
GRANT CREATE SYNONYM TO my-user;
GRANT CREATE VIEW TO my-user;
GRANT CREATE TABLE TO my-user;
GRANT GATHER_SYSTEM_STATISTICS TO my-user;
GRANT CREATE PROCEDURE TO my-user;
GRANT CREATE TRIGGER TO my-user;
GRANT CREATE DATABASE LINK TO my-user;
GRANT CREATE TYPE TO my-user;

这就是 Rails 提示我的:
Please provide the SYSTEM password for your Oracle installation (set ORACLE_SYSTEM_PASSWORD to avoid this prompt)

我不明白为什么,如 my-user应该具有其自己的架构所需的所有权限。

有任何想法吗?

最佳答案

看来 rake db:create 需要 SYSTEM 密码硬编码在 gem 中。

def create
system_password = ENV.fetch('ORACLE_SYSTEM_PASSWORD') {
print "Please provide the SYSTEM password for your Oracle installation (set ORACLE_SYSTEM_PASSWORD to avoid this prompt)\n>"
$stdin.gets.strip
}
establish_connection(@config.merge('username' => 'SYSTEM', 'password' => system_password))
begin
connection.execute "CREATE USER #{@config['username']} IDENTIFIED BY #{@config['password']}"
rescue => e
if e.message =~ /ORA-01920/ # user name conflicts with another user or role name
connection.execute "ALTER USER #{@config['username']} IDENTIFIED BY #{@config['password']}"
else
raise e
end
end
connection.execute "GRANT unlimited tablespace TO #{@config['username']}"
connection.execute "GRANT create session TO #{@config['username']}"
connection.execute "GRANT create table TO #{@config['username']}"
connection.execute "GRANT create view TO #{@config['username']}"
connection.execute "GRANT create sequence TO #{@config['username']}"
end

Source

如您所见,它实际上也是 creates您在 database.yml 中设置的用户并赋予它一些特权。

最好跳过 rake db:create .您始终可以在生产环境中手动创建一次数据库,而在开发/测试环境中,可以授予 SYSTEM 访问您的 Ruby 代码的权限。

关于ruby-on-rails - Rails + Oracle + oracle_enchanced 适配器 : db:create asks for SYSTEM password?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31783599/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com