欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

windows环境下,ruby 连接mysql 报错

程序员文章站 2022-03-28 20:41:56
...
mysqlruby

require "D:/ruby-mysql/ruby-mysql-0.2.6/mysql"
begin
#尝试连接mysql数据库
my = Mysql.connect("localhost","root","123456","test")
#连接成功,显示Mysql数据库版本
puts my.get_server_info
rescue Mysql::Error => err
#如果失败,显示错误信息
puts "错误代码:#{err.errno}"
puts "错误信息:#{err.error}"
ensure
my.close if my
end

运行以上代码,报这样的错误:
D:/ruby-mysql/ruby-mysql-0.2.6/mysql.rb:1019:in read': Packets out of order: 0 (RuntimeError)
from D:/ruby-mysql/ruby-mysql-0.2.6/mysql.rb:444:in
read'
from D:/ruby-mysql/ruby-mysql-0.2.6/mysql.rb:110:in real_connect'
from D:/ruby-mysql/ruby-mysql-0.2.6/mysql.rb:91:in
initialize'
from D:/ruby-mysql/ruby-mysql-0.2.6/mysql.rb:1085:in new'
from D:/ruby-mysql/ruby-mysql-0.2.6/mysql.rb:1085:in
real_connect'
from D:/软件/eclipse-standard-kepler-SR2-win32/hello/testDb.rb:3:in `'

项目要用到ruby,新人,求大神帮忙,搞了一天了,没连上

相关标签: mysql ruby