gpt4 book ai didi

mysql - Ruby gem 加载失败 - 无法加载驱动程序 'MySQL'

转载 作者:行者123 更新时间:2023-11-29 12:13:48 24 4
gpt4 key购买 nike

我有一个已经运行多年的应用程序。然后我们将服务器迁移到 Ubuntu 15.04 并安装了 Ruby。

sudo apt-get install curl
sudo apt-get install ruby2.1
sudo gem update --system
sudo apt-get install rake
apt-get install ruby-dev
sudo gem install amatch
sudo apt-get install libmysqlclient-dev
sudo gem install -r dbi
sudo gem install -r mysql dbd-mysql

然后我们运行程序并得到这个错误..

/var/lib/gems/2.1.0/gems/dbi-0.4.5/lib/dbi.rb:300:in `block in load_driver': Unable to load driver 'MySQL' (underlying error: uninitialized constant DBI::DBD::MySQL) (DBI::InterfaceError)
from /usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
from /var/lib/gems/2.1.0/gems/dbi-0.4.5/lib/dbi.rb:242:in `load_driver'
from /var/lib/gems/2.1.0/gems/dbi-0.4.5/lib/dbi.rb:160:in `_get_full_driver'
from /var/lib/gems/2.1.0/gems/dbi-0.4.5/lib/dbi.rb:145:in `connect'

程序本身(用户名和密码已更改)

#!/usr/bin/ruby
require "rubygems"
gem 'mysql'
gem 'dbi'
require "dbi"
require "amatch"

include Amatch

name_sub = { "unit" => "un",
"unt" => "un",
"tract" => "tr",
"estate" => "est",
"university" => "univ",
"trust" => "trst" }

op_sub = { "partnership" => "PS",
"partnershp" => "PS",
"partner" => "PS",
"prtnr" => "PS",
"ptnr" => "PS",
"ptnrsp" => "PS",
"corporation" => "C",
"corp" => "C",
"company" => "co",
"incorporation" => "I",
"inc" => "I",
"oil" => "O",
"gas" => "G",
"exploration" => "E",
"production" => "P",
"operating" => "oper",
"energy" => "engy",
"management" => "mgmt",
"resources" => "res",
"minerals" => "min",
"petroleum" => "pet" }


def mangle(s, dictionary = {})
return "" unless s
# lowercase | special case | alphanumerics only
s.downcase().gsub(/l.l.c./, 'llc').gsub(/\W/, " ").split(" ").map do |word|
dictionary.fetch(word, word)
end.join(' ')
end

stop_attempts = -1
PRODUCTION = false

begin
# now the actual code



# development database
DBI.connect("dbi:MySQL:database=matching;" "host=enus", "mott", "bM^7ezOqYyn") do |outdb|
DBI.connect("dbi:MySQL:database=ownership;" "host=enus", "mott", "bM^7ezOqYyn") do |lease_db|

# re-create phase3 table
outdb.do("drop table if exists phase3")
sql = "create table phase3 (" +
"id bigint not null auto_increment primary key, " +
"lod_id bigint, rrc_id bigint, district varchar(255), " +
"name_percent float, rrc_lease_no varchar(255)," +
"op_percent float, field_percent float, total float, " +
"key k1 (lod_id), key k2 (rrc_id), key k3 (district), " +...

详尽的 Google 搜索找到了安装 dbd-mysql 的建议,以及其他建议,但没有任何效果。

那么这里出了什么问题呢?我不是一个 Ruby 人,我是一个底层的 IT 人,试图让这个程序恢复运行。

最佳答案

看起来区分大小写的文件系统存在一些问题,在我的 Mac 上尝试此操作,但我能够通过将连接字符串从“MySQL”更改为“Mysql”来进行测试,例如:

2.1.5@test_dbi ~$ cat test_dbi.rb 
#!/usr/bin/ruby
require "rubygems"
require 'dbi'
DBI.connect("dbi:Mysql:database=matching;" "host=enus", "mott", "bM^7ezOqYyn")
2.1.5@test_dbi ~$

关于mysql - Ruby gem 加载失败 - 无法加载驱动程序 'MySQL',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30204019/

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