Tag: mysql2

在Rails中用主键创build表和问题

当我尝试在使用Mysql2作为数据库pipe理器的Rails中运行以下代码时: rake db:migrate 我得到以下错误: rake aborted! "Mysql2::Error: All parts of a PRIMARY KEY must be NOT NULL:" 为什么我得到这个错误,如果表中的主键默认不是“null”? 迁移代码,但是: class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string "first_name" t.timestamps end end end

请安装mysql适配器'gem install activerecord-mysql-adapter'

我很难find解决这个问题的方法。 我收到错误: Please install the mysql adapter: 'gem install activerecord-mysql-adapter' /Users/ Andy/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/rubygems_integration.rb:143:in `block in replace_gem': Please install the mysql adapter: `gem install activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.) (LoadError) from /Users/ Andy /mysql2/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/mysql_adapter.rb:5:in `<top (required)>' from /Users/ Andy /mysql2/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in `require' from /Users/ Andy /mysql2/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in `block in require' from /Users/ […]

Mysql 5.6在Mac OSX上头疼

我的几位同事和我最近从我们的Mac上使用自制软件从MySQL 5.5升级到MySQL 5.6,在升级我们的服务器之前在本地进行testing。 由于这次升级,我们都在运行我们的rails代码时遇到了间歇性的MySQL错误: Lost connection to MySQL server at 'sending authentication information', system error: 32 我们尝试在我们的数据库中重新制作用户名和密码,并且增加了连接超时,但是没有解决问题。 错误日志没有提到这个问题。 我们遇到问题时唯一的解决方法是杀死mysql并重新启动它。 我甚至在命令行中最近使用mysql -u root -p注意到了这个错误。 看来,一旦我开始得到这个错误,无论用户使用什么用户名,我都不能超过当前的连接数。 如果我closures连接,那么我可以重新打开一个连接。 我们有以下的环境: 我们中的一些人:Rails 3.2,Ruby 2,mysql2 0.3.13,MySQL 5.6.12,Mac OSX 10.8.4 其他人:Rails 3.2,Ruby 1.9,mysql2 0.3.13,MySQL 5.6.10,Mac OSX 10.8.4 任何想法可能是什么原因造成的? 谢谢! 朱丽叶

左侧外部joinRails 4

我有3个模型: class Student < ActiveRecord::Base has_many :student_enrollments, dependent: :destroy has_many :courses, through: :student_enrollments end class Course < ActiveRecord::Base has_many :student_enrollments, dependent: :destroy has_many :students, through: :student_enrollments end class StudentEnrollment < ActiveRecord::Base belongs_to :student belongs_to :course end 我希望查询课程表中不存在的与某个学生关联的StudentEnrollments表中的课程列表。 我发现也许左连接是要走的路,但似乎rails中的joins()只接受一个表作为参数。 我认为会执行我想要的SQL查询是: SELECT * FROM Courses c LEFT JOIN StudentEnrollment se ON c.id = se.course_id WHERE se.id IS […]

错误:无法构buildgem本机扩展(rails 3.2.3上的mysql2)

我试图安装与Rails 3.2.3的MySQL2的gem,它失败了: ★ bundle install Fetching gem metadata from https://rubygems.org/……… Using rake (0.9.2.2) Using i18n (0.6.0) Using multi_json (1.2.0) Using activesupport (3.2.3) Using builder (3.0.0) Using activemodel (3.2.3) Using erubis (2.7.0) Using journey (1.0.3) Using rack (1.4.1) Using rack-cache (1.2) Using rack-test (0.6.1) Using hike (1.2.1) Using tilt (1.3.3) Using sprockets (2.1.2) Using actionpack (3.2.3) […]

Gem :: LoadError for mysql2 gem,但它已经在Gemfile中

Gem::LoadError Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile 加载以下文件时发生此错误: active_record/base 这是我在运行rails服务器上的错误。 The mysql2 gem has been added to the Gemfile as well. 我已经完成bundle install ,并尝试重新启动服务器,但仍然得到错误。

Rails 4 – Gem :: LoadError:为数据库适配器指定'mysql2',但没有加载gem

在我的gemfile中我有: gem 'mysql2' 我的database.yml如下所示: default: &default adapter: mysql2 database: <%= ENV['db_name'] %> username: <%= ENV['db_user'] %> password: <%= ENV['db_pass'] %> host: <%= ENV['db_host'] %> pool: 32 socket: <%= ENV['socket'] %> development: <<: *default production: <<: *default 我已经运行bundle update和bundle install ,我的Gemfile.lock显示mysql2。 但是当我运行rake db:migrate我在计算机和登台服务器上都得到了这个: myproject.com(master)$ rake db:migrate WARNING: Use strings for Figaro configuration. 10000012508 was converted to […]

Ruby gem mysql2安装失败

当我尝试安装mysql2的gem,它失败,没有明显的错误。 有谁知道该怎么做才能解决这个mysql2安装? Tanner-Smiths-MacBook-Pro:Humans_vs_Zombies_Parse tanner $ sudo gem install mysql2build立本地扩展。 这可能需要一段时间… 错误:安装mysql2时出错: 错误:无法构buildgem本机扩展。 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb 检查rb_thread_blocking_region()…不 在-lmysqlclient中检查mysql_query()…不 在-lm中检查main()…是的 在-lmysqlclient中检查mysql_query()…不 在-lz中检查main()…是的 在-lmysqlclient中检查mysql_query()…不 检查main()in -lsocket …不 在-lmysqlclient中检查mysql_query()…不 检查main()in -lnsl … no 在-lmysqlclient中检查mysql_query()…不 在-lmygcc中检查main()…不 在-lmysqlclient中检查mysql_query()…不 *** extconf.rb失败*** 由于某种原因无法创buildMakefile,可能缺乏 必要的库和/或标题。 检查mkmf.log文件以获取更多信息 细节。 您可能需要configuration选项。 提供的configuration选项: –with-OPT-DIR –without-OPT-DIR –with-OPT-包括 –without-OPT-包括= $ {停用DIR} /包括 –with-OPT-LIB –without-OPT-LIB = $ {select-DIR} / lib目录 –with-MAKE-PROG –without-MAKE-PROG […]

在Windows 7上安装Ruby MYSQL2 gem安装

我试图在Windows 7上安装mysql2 gem我从mysql网站下载了连接器,并将libmysql.dll放在ruby200 \ bin 然后做gem安装mysql2 这些是我在这里昏迷的结果? Temporarily enhancing PATH to include DevKit… Building native extensions. This could take a while… ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. C:/Ruby200/bin/ruby.exe extconf.rb checking for rb_thread_blocking_region()… yes checking for rb_wait_for_single_fd()… yes checking for rb_hash_dup()… yes checking for rb_intern3()… yes *** extconf.rb failed *** Could […]

rails服务器无法启动mysql2在OSX 10.6.5上使用rvm&ruby 1.9.2-p0

当我启动rails服务器时出现以下错误: $ rails server /Users/ssmith/.rvm/gems/ruby-1.9.2-p0/gems/mysql2-0.2.6/lib/mysql2.rb:7:in `require': dlopen(/Users/ssmith/.rvm/gems/ruby-1.9.2-p0/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib (LoadError) Referenced from: /Users/ssmith/.rvm/gems/ruby-1.9.2-p0/gems/mysql2- 0.2.6/lib/mysql2/mysql2.bundle Reason: image not found – /Users/ssmith/.rvm/gems/ruby-1.9.2-p0/gems/mysql2- 0.2.6/lib/mysql2/mysql2.bundle 在rvm使用ruby-1.9.2-p0命令后,我使用以下命令安装了mysql2: $ gem install mysql2 — –with-mysql-dir=/usr/local/mysql –with-mysql-config=/usr/local/mysql/bin/mysql_config Building native extensions. This could take a while… Successfully installed mysql2-0.2.6 1 gem installed Installing ri documentation for mysql2-0.2.6… Enclosing class/module 'mMysql2' for […]