当使用mysql2进行查询时,我总是收到警告
/usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:463: warning: :database_timezone option must be :utc or :local - defaulting to :local
Run Code Online (Sandbox Code Playgroud)
我确实看到了Timezones的一个选项
Mysql2现在支持两个时区选项:
:database_timezone - this is the timezone Mysql2 will assume fields are already stored as, and will use this when creating the initial Time objects in ruby
:application_timezone - this is the timezone Mysql2 will convert to before finally handing back to the caller
Run Code Online (Sandbox Code Playgroud)
有谁知道,如何使用,以及在哪里设置此选项?
谢谢.
我尝试mysql2在Windows 7 32位上安装gem.
我跑:
gem install mysql2
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
ERROR: Error installing mysql2:
The 'mysql2' native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
Run Code Online (Sandbox Code Playgroud)
任何可能导致此错误的想法,以及如何解决这个问题?
UPDATE
我做了这里描述的所有事情,但我无法弄清楚最后一步:
gem install mysql2 --
'--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.1\lib\opt"
--with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.1\include"'
Run Code Online (Sandbox Code Playgroud)
我知道我应该改变系统中正确路径的路径,但是在WAMP MySQL安装中找不到lib\opt和include目录.我使用WAMP 2.1.
请指教.
我使用sqlite构建了我的Rails 3应用程序,现在我正在尝试切换到MySQL.
我创建了一个新的MySQL数据库,相应地更改了database.yml,我在我的gemfile(gem 'mysql2', '< 0.3')中添加了一个旧版本的mysql2 gem,它应该可以更好地使用Rails 3.
我可以启动开发服务器.当我访问页面时,我得到一个Mysql2::Error(Table 'twitter_quiz_development.users' doesn't exist).哪个没问题 - 我仍然需要将架构添加到新的数据库中.这是我遇到麻烦的地方:
rake db:schema:load返回这个讨厌的错误.
这里找到的解决方案对我不起作用.gem pristine --all归还这个.
如果有帮助,我正在运行Ubuntu 11.
看来该错误与JSON有关,但我不知道如何解决这个问题.谢谢.
我在OS X Lion上使用MAMP2,rvm,我无法使用mysql2 gem来使用我的Rails应用程序.
我已经关注了这篇博客文章http://blog.mirotin.net/35/mamp-1-9-5-mysql-5-5-9-and-ruby-mysql2和这篇http://www.pa -ket.com/blog/show/12-osx-ruby-mysql2-gem-python-mysqldb-using-mamp
这些是步骤:
$ cd /tmp
$ mv /Users/yourname/Desktop/mysql-5.5.9.tar.gz .
$ tar xf mysql-5.5.9.tar.gz
$ cd mysql-5.5.9
$ brew install cmake
$ cmake . -DMYSQL_UNIX_ADDR=/Applications/MAMP/tmp/mysql/mysql.sock -DCMAKE_INSTALL_PREFIX=/Applications/MAMP/Library
Run Code Online (Sandbox Code Playgroud)
此步骤失败:
$ make -j 3
Run Code Online (Sandbox Code Playgroud)
在/tmp/mysql-5.5.9/CMakeFiles/Makefile2中对'my_atomic-t.dir'进行单元测试后,make -j 3'就可以了.
$ cp libmysql/*.dylib /Applications/MAMP/Library/lib/
$ mkdir -p /Applications/MAMP/Library/include/mysql
$ cp include/* /Applications/MAMP/Library/include/mysql
$ env ARCHFLAGS="-arch x86_64" gem install mysql2 -v 0.2.11 -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
Building native extensions. This could take a while...
Successfully installed mysql2-0.2.11
1 gem installed
Installing ri …Run Code Online (Sandbox Code Playgroud) 我是RoR的新手,我正在尝试安装Mysql2 -v'0.3.11'.我有OS X Mountain Lion,rails 3.2.6,ruby 1.9.3.
以下是我得到的错误.我到处看,没有找到任何东西.
$gem install mysql2 -v '0.3.11'
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile
make
compiling client.c
In file included from client.c:1:
In file included from ./mysql2_ext.h:8:
In file included from /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby.h:32:
/Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/ruby.h:105:37: error: 'ruby_check_sizeof_long' declared as an …Run Code Online (Sandbox Code Playgroud) 当使用ActiveRecord运行mysql查询时Class.connection.execute('query here'),结果是一个数组,而不是postgres中的哈希.这是使用mysql和mysql2适配器测试的,即使默认情况mysql2是将查询结果作为哈希返回.
如何ActiveRecord更改连接上的配置选项以将查询结果作为哈希返回?我可以不用ActiveRecord它,我应该使用原始mysql2客户端吗?
我目前正在构建一个需要mysql2 gem的RoR项目.我成功安装了宝石.因为它出现在我的宝石列表中.
[root@vc2cmmka035538n simple_cms]# gem list
*** LOCAL GEMS ***
actionmailer (3.2.3)
actionpack (3.2.3)
activemodel (3.2.3)
activerecord (3.2.3)
activeresource (3.2.3)
activesupport (3.2.14, 3.2.3)
arel (3.0.2)
bigdecimal (1.1.0)
builder (3.2.2, 3.0.0)
bundler (1.1.5)
c2c_linux_patch_utilities (0.29.0)
chef (11.6.2)
chef-zero (1.6)
debug_me (0.5.1)
diff-lcs (1.1.3)
erubis (2.7.0)
gelf (1.1.3)
hashie (2.0.5)
highline (1.6.19)
hike (1.2.1)
i18n (0.6.5)
io-console (0.3)
ipaddress (0.8.0)
journey (1.0.3)
json (1.7.7, 1.5.5)
knife-lastrun (0.0.4)
mail (2.4.4)
mime-types (1.25)
minitest (2.5.1)
mixlib-authentication (1.3.0)
mixlib-cli (1.3.0)
mixlib-config (1.1.2)
mixlib-log (1.6.0)
mixlib-shellout …Run Code Online (Sandbox Code Playgroud) 有谁知道造成这种情况的原因以及如何解决它?我正在尝试为我的项目安装 ruby gem,这是一个在 Rails 3 上运行的旧项目,但我在 ubuntu 20.04 上运行。我所做的基本上就是运行捆绑安装,然后我就可以让除了这个 ruby gem 之外的所有东西都工作了。请指教!
\ncurrent directory: /home/decil/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/mysql2-0.3.21/ext/mysql2\nmake "DESTDIR=" clean\n\ncurrent directory: /home/decil/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/mysql2-0.3.21/ext/mysql2\nmake "DESTDIR="\ncompiling client.c\nclient.c: In function \xe2\x80\x98nogvl_read_query_result\xe2\x80\x99:\nclient.c:439:3: error: unknown type name \xe2\x80\x98my_bool\xe2\x80\x99; did you mean \xe2\x80\x98bool\xe2\x80\x99?\n 439 | my_bool res = mysql_read_query_result(client);\n | ^~~~~~~\n | bool\nclient.c: In function \xe2\x80\x98rb_query\xe2\x80\x99:\nclient.c:687:14: warning: passing argument 1 of \xe2\x80\x98rb_rescue2\xe2\x80\x99 from incompatible pointer type [-Wincompatible-pointer-types]\n 687 | rb_rescue2(do_send_query, (VALUE)&args, disconnect_and_raise, self, rb_eException, (VALUE)0);\n | ^~~~~~~~~~~~~\n | |\n | VALUE (*)(void *) {aka long unsigned int (*)(void *)}\nIn …Run Code Online (Sandbox Code Playgroud) 我正在使用 ruby 3.0.1p64 并使用 macOS bigsur 11.04 mysql 安装并运行
捆绑安装要求我安装 mysql2
我正在尝试像这样安装 mysql2 gem:
sudo gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'
Run Code Online (Sandbox Code Playgroud)
我得到这个:
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
current directory: /Users/henri/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/mysql2-0.5.3/ext/mysql2
/Users/henri/.rbenv/versions/3.0.1/bin/ruby -I /Users/henri/.rbenv/versions/3.0.1/lib/ruby/3.0.0 -r ./siteconf20210617-53969-y4phap.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries …Run Code Online (Sandbox Code Playgroud) 我在 Windows 8.1 机器上安装 mysql2 gem 时遇到了一些问题。我按照这篇文章中的说明进行操作:
安装mysql2gem,我没有收到任何错误消息。
我跟着这个
bundle install
Run Code Online (Sandbox Code Playgroud)
命令,并确认安装了以下 gems(使用 bundle show),确认我安装了以下 gems:
Using devise (3.2.2)
Using mysql2 (0.3.14)
Run Code Online (Sandbox Code Playgroud)
然后我尝试这样做:
rails generate devise:install
Run Code Online (Sandbox Code Playgroud)
这就是我得到的:
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14/lib/mysql2.rb:8:in `require': 126: The specified module could not be found.
- C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14/lib/mysql2/mysql2.so (LoadError)
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14/lib/mysql2.rb:8:in `<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `block in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.1/lib/bundler.rb:131:in `require' …Run Code Online (Sandbox Code Playgroud)