0
我的Gemfile:Rails和mysql2寶石畸形報文
source 'https://rubygems.org'
gem 'rails', '4.2.8'
gem 'bootstrap-sass', '~> 3.3.7'
gem 'font-awesome-rails'
gem 'sqlite3'
gem 'mysql2'
gem 'sass-rails', '~> 5.0.4'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
group :doc do
gem 'sdoc', require: false
end
我的數據庫配置:
default: &default
adapter: mysql2
pool: 25
timeout: 5000
encoding: utf8
development:
<<: *default
host: 127.0.0.1
database: asteriskcdrdb
username: root
password: pwd3lfga
port: 13306
在控制檯我有這樣的錯誤後,我啓動控制檯,並嘗試從內部數據庫表中讀取:
Mysql2::Error: Malformed packet
from /Users/michele/.rvm/gems/ruby-2.2.2/gems/mysql2-0.4.6/lib/mysql2/client.rb:89:in `connect'
from /Users/michele/.rvm/gems/ruby-2.2.2/gems/mysql2-0.4.6/lib/mysql2/client.rb:89:in `initialize'
from /Users/michele/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.8/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `new'
您是否試過這個解決方案[1]?增加了:local_infile => true作爲選項。 [1] https://stackoverflow.com/questions/8790874/load-data-local-infile-causes-malformed-packet-error-with-mysql2-gem – tingel2k
@ tingel2k在哪裏把這個選項?在database.yml中? – michael
由控制檯通過此命令嘗試: a = Mysql2 :: Client.new(:username =>'root',:host =>'127.0.0.1',:password =>'pwd3lfga',:database =>'asteriskcdrdb '::local_infile => true,:port => 13306) 輸出Rails控制檯:Mysql2 ::錯誤:格式錯誤的數據包 – michael