gpt4 book ai didi

mysql - ruby mysql连接错误

转载 作者:数据小太阳 更新时间:2023-10-29 08:51:13 26 4
gpt4 key购买 nike

我正在使用 MySQL 和 ruby​​ 1.8.6。我想连接到 MySQL,因此我正在使用事件记录 gem。我的代码是

def initialize

@db_adapter = "mysql2"
@db_host = "localhost"
@db_database = "database_name"
@db_user = "root"
@db_password = "root123"
con = nil

end

def database_connection
con = ActiveRecord::Base.establish_connection(
:adapter => $db_adapter,
:host => $db_host,
:database => $db_database,
:user => $db_user,
:password => $db_password
)

return con
end

但是当我尝试连接时,它给了我这个错误

/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:76:in `establish_connection': Please install the  adapter: `gem install activerecord--adapter` (no such file to load -- active_record/connection_adapters/_adapter) (RuntimeError)
from /cmf/samnew/build/Controller/databaseConnection.rb:32:in `database_connection'
from controller.rb:23

最佳答案

错误显示未安装 activerecord--adapter gem。您可以使用命令安装 gem

gem install activerecord--adapter.

关于mysql - ruby mysql连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12507323/

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