我想使用开源代码将 Stack Overflow 数据导入我的 MySQL 数据库:
if ARGV.size != 5
puts "Usage load.rb Usage load.rb <XML file path> <db host> <db user> <db pass> <db name>"
exit 1
end
my = Mysql::new(ARGV[1], ARGV[2], ARGV[3], ARGV[4])
puts "Loading badges"
parser = XML::SaxParser.file(ARGV[0] + '/badges.xml')
parser.callbacks = BadgeCallbacks.new(my)
parser.parse
我收到以下错误:
load.rb:129:in `new': Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2) (Mysql::Error)
from load.rb:129:in `<main>'
mac@localhost:[~/rubycode]$ruby load.rb '~/rubycode/stackoverflow_1' 'localhost' 'test' 'test' 'stackflow'
load.rb:129:in `new': Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2) (Mysql::Error)
from load.rb:129:in `<main>'
我确实使用 RVM 安装了 MySQL gem。