【ruby on rails mysql2 error】教程文章相关的互联网学习教程文章

ruby on rails mysql2 error【代码】

Q: am having some problems when trying to install mysql2 gem for Rails. When I try to install it by running bundle install or gem install mysql2 it gives me the following error:Error installing mysql2: ERROR: Failed to build gem native extension.How can I fix this and successfully install mysql2?A: On Ubuntu/Debian and other distributions using aptitude:sudo apt-get install libmysql-ruby l...

使用ruby 2.0的Mysql 2.9.1错误【代码】

OS Ubuntu 12.04.我从https://github.com/rails/rails.git克隆了rails4.0.0beta1.我有ruby 2.0.0p0(2013-02-24修订版39474),当我尝试“捆绑安装”时,我有以下错误消息:Installing mysql (2.9.1) Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension./home/zergood/.rvm/rubies/ruby-2.0.0-p0/bin/ruby extconf.rb checking for mysql_query()... -lmysqlclient checking for main() in -lm... y...

Ruby Mysql无法连接到localhost(10061)【代码】

我从Lynda跟踪ruby on rails课程,我在使用Windows命令行连接数据库时遇到问题. 我可以使用“mysql -u username -p”连接到数据库,然后输入密码.我可以创建数据库而且没有问题. 现在执行时:rake db:schema:dump在我的应用程序文件夹“simple_cms”中,我得到以下内容:rake aborted! Can't connect to MySQL server on 'localhost' (10061)Tasks: TOP => db:schema:dump (See full trace by running task with --trace)运行跟踪给出...

为什么在MySQL时ruby无法检测到无效的编码?【代码】

我正在从YouTube提取一些RSS提要,这些提要具有无效的UTF8.我可以使用创建一个类似的ruby字符串bad_utf8 = "\u{61B36}" bad_utf8.encoding # => #<Encoding:UTF-8> bad_utf8.valid_encoding? # => trueRuby认为这是有效的UTF-8编码,我很确定这不是. 当与Mysql交谈时,我得到了这样的错误require 'mysql2' client = Mysql2::Client.new(:host => "localhost", :username => "root") client.query("use test");bad_utf8 = "\u{61B36}" ...

Ruby on Rails数据库迁移不在MySQL表中创建外键【代码】

我试图修改Ruby on Rails应用程序中的数据库迁移.我使用MySQL作为我的数据库,并希望将外键添加到正在创建的表中.我正在使用以下代码,并且在遵循在适当的列上创建空值的规范时,不应用外键约束.class CreateBookCheckOuts < ActiveRecord::Migrationdef self.upcreate_table :book_check_outs do |t|t.integer :book_id, :null => false, :options =>"CONSTRAINT fk_book_check_out_books REFERENCES books(id)"t.integer :person_id...

Ruby使用MySQL问题记录【图】

使用gem安装mysql2的时候提示以下错误extconf.rb:2:in `require 1.使用gem安装mysql2的时候提示以下错误extconf.rb:2:in `require: no such file to load -- mkmf (LoadError) from extconf.rb:2 Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /usr/bin/ruby1.8 extconf.rb extconf.rb:2:in `require: no such file to load -- mkmf (...

mysql-Rake上的Ruby on Rails出现问题【代码】

我是Rails的新手,所以请原谅我缺乏理解.我已经通过RubyGems安装了最新版本的RubyGems,Ruby,Rails,Rake和MySQL等,但是在开始制作基本的Rails应用程序时遇到了这个问题:Icarus:temporary atg$rails new people... (output omitted) ... Icarus:temporary atg$cd people Icarus:people atg$rake db:create (in /Users/atg/temporary/people) rake aborted! uninitialized constant Bundler /Users/atg/temporary/people/Rakefile:4 (...

检查-lmysqlclient中的mysql_query() – ruby​​ gem mysql2错误(Ubuntu 12.04 LTS)【代码】

我正在尝试安装mysql2 gem(使用Ubuntu 12.04 LTS),并且在尝试安装gem时出现以下错误:checking for mysql_query() in -lmysqlclient... no checking for main() in -lm... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lz... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lsocket... no checking for mysql_query() in -lmysqlclient... no checking for m...

Ruby中的MySQL SQL / DDL解析器/验证器(在Rails上)

我正在寻找Rails的工具或库来验证/解析可能是SQL和/或DDL的查询.目前,我没有找到任何可以快速轻松使用的内容. 我发现Parslet可用于定义自己的SQL / DDL语言来验证SQL / DDL语句. 要达到的目标是拥有一个工具,我们可以在数据库上运行之前验证SQL / DDL语法.例如,DDL查询与MySQL不是事务性的,因此,如果一个语句在较大的脚本中间失败,我们需要从故障点恢复数据库或运行脚本(这不是真正用户友好的).如果我们至少可以验证语法,我们将通过...

mysql – 如何告诉heroku使用rails 3和ruby 1.9.2为新创建的应用程序?【代码】

我使用rvm ruby??1.9.2p0和rails 3.0.1在我的机器上创建了一个新的应用程序,并执行了以下操作:rails new -J -d mysql appname git init git add . git commit heroku create并创建了应用程序.但当我这样做时:heroku rake db:create --trace我明白了:Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Couldn't create database for {"reconnect"=>false, "encoding"=>"utf8", "username"=...

Ruby 连接 Mysql - MySql2【代码】

你需要使用 –with-mysql-config 配置 mysql_config 的路径,如: –with-mysql-config=/some/random/path/bin/mysql_config。 连接 连接数据库语法如下:client = Mysql2::Client.new(:host => "localhost", :username => "root")更多参数可以查看 http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/MysqlAdapter.html。 查询results = client.query("SELECT * FROM users WHERE group=‘githubbers‘")特殊字...

sysread:使用Ruby和mysql时,系统调用中断(Errno :: EINTR)【代码】

我正在使用机械化方式抓取站点并推送到mysql数据库.我经常遇到这些sys读取错误,我不确定解决方案是什么.我正在使用Ruby-mysql gem.解决方法:我在做完全相同的事情(使mysql机械化),我通过用begin / rescue / end子句包装mysql调用来解决它:beginmysql_insert data rescue Interrupt, Errno::EINTRmysql_close connectionconnection = mysql_connectretry end请注意,这会将您的代码置于无限循环中,如果您在实际环境中使用它,我建议在...

mysql – Ruby on Rails中的自定义搜索【代码】

我正在尝试在我的Rails应用程序中实现自定义搜索功能. 我有3个表用户公司和公司用户 我宣布的关系如下class CompanyUser < ActiveRecord::Basebelongs_to :companybelongs_to :user ... end在Company.rbhas_many :company_users, dependent: :destroy has_many :users, through: :company_users在User.rb中has_many :company_users, dependent: :destroy has_many :companies, through: :company_users在我的视图页面中,我列出了所...

mysql-在Ruby中运行任意SQL查询

我刚刚承担了在工作中自动执行报告任务的任务.以前,有人会使用GUI工具在MySQL数据库上运行大型任意SELECT,然后使用该工具将结果导出到CSV.现在,我想编写一个Ruby脚本来执行此操作. 我了解Ruby中的FasterCSV,但就SQL查询而言,我仅使用ActiveRecord,在此通常不编写查询,而是使用模型和关联.我上次用代码编写完整的SQL是在编写PHP时. 在Ruby中最简单的方法是什么?我应该使用ActiveRecord吗?解决方法:如果您正在编写复杂的应用程序,则...

mysql – 你最喜欢的Ruby on Rails书籍是什么?为什么?

我正在寻找一些关于RoR的书籍,以帮助自学如何构建可扩展的RoR应用程序.我已经阅读了RailsS??pace的书,并且今晚正在启动Rails Way书. 一些感兴趣的主题是: > REST – 考虑使用亚马逊的SimpleDB>有效使用RSpec> memcached – 服务器架构和代码实现> mongrel – 服务器架构> MySQL解决方法:对于Rails的新人来说,Agile Web Development With Rails始终是一个很好的起点. 我真的很喜欢这本书,因为它以示例驱动的方式教你框架.他们逐...