Questions tagged [mysql2]

The Mysql2 gem is meant to serve the extremely common use-case of connecting, querying and iterating on results.

The mysql2 gem is an interface for accessing MySQL databases from Ruby. This gem is an incompatible improvement over the original mysql gem.

Links:

907 questions
7
votes
1 answer

Rails - Library not loaded: @@HOMEBREW_PREFIX@@/opt/openssl/lib/libssl.1.0.0.dylib (LoadError)

I am fighting with an error that occurs when I run rails s: /Users/adam/.rvm/gems/ruby-2.0.0-p481/gems/mysql2-0.3.16/lib/mysql2.rb:8:in `require':…
user984621
  • 46,344
  • 73
  • 224
  • 412
7
votes
1 answer

Get ActiveRecord MySQL Query result as a hash, not array

When running a mysql query with ActiveRecord with Class.connection.execute('query here'), the result is an array, as opposed to a hash in postgres. This is tested with both mysql and mysql2 adapters, even though the default for mysql2 is to return…
Solomon
  • 6,145
  • 3
  • 25
  • 34
7
votes
3 answers

Ruby script connect to Mysql2 using database.yml without Rails

I'd like to connect to a mysql database using the mysql2 gem in a Ruby script but without Rails or ActiveRecord, yet reading the config/database.yml file so as not to expose the user name and password directly inside the Ruby script. I can connect…
kakubei
  • 5,321
  • 4
  • 44
  • 66
7
votes
6 answers

mysql2 gem Can't build native extensions

Our intern's computer is having problems installing the mysql2 gem. We just upgraded his computer from OS X 10.6 to 10.8 (Mountain Lion). I have tried installing mysql through homebrew and through the 64 bit DMG installer. I also tried symlinking…
Tyler DeWitt
  • 23,366
  • 38
  • 119
  • 196
6
votes
3 answers

Can't get mysql2 gem to work with MAMP2 and RVM on Lion, Rails3 app

I am using MAMP2, rvm on OS X Lion and there is no way I can get mysql2 gem to work with my Rails app. I've followed this blog post http://blog.mirotin.net/35/mamp-1-9-5-mysql-5-5-9-and-ruby-mysql2 and this one…
Mirko
  • 5,207
  • 2
  • 37
  • 33
6
votes
5 answers

unable to install mysql2 Gem on Bigsur

I am using ruby 3.0.1p64 and using macOS bigsur 11.04 mysql installed and running Bundle install asks me to install mysql2 I am trying to install mysql2 gem like this: sudo gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/' and I am…
Henri
  • 983
  • 3
  • 11
  • 29
6
votes
4 answers

How to get insertId for MySQL using Mysql2 in Node with async and pool?

I am trying to use async await with mysql2 and pooling but I think I doing things wrong. Below is my code (as I said, I am not really sure if I am doing things right here). const pool = mysql.createPool({ host: 'localhost', user:…
Hejhejhej123
  • 875
  • 4
  • 12
  • 25
6
votes
3 answers

mysql2 Ruby Gem failed to install ubuntu 20.04

Does anyone know what causes this and how I can fix it? I am trying to install a ruby gem for my project which is an old project running on rails 3, but I'm running on ubuntu 20.04. All I am doing is essentially running bundle install and then I get…
Ryan Glenn
  • 1,325
  • 4
  • 17
  • 30
6
votes
2 answers

Problem with Rails 3 and MySQL related to JSON dependency in ActiveSupport

I built my Rails 3 app using sqlite and now I'm trying to switch over to MySQL. I created a new MySQL db, changed database.yml accordingly, and I added an older version of the mysql2 gem to my gemfile (gem 'mysql2', '< 0.3') which is supposed to…
user94154
  • 16,176
  • 20
  • 77
  • 116
6
votes
6 answers

How to use "mysql2" gem in Rails 3 application on Windows 7?

I try to install the mysql2 gem on Windows 7 32-bit. I run: gem install mysql2 and I get the following error: ERROR: Error installing mysql2: The 'mysql2' native gem requires installed build tools. Please update your PATH to include build…
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
6
votes
2 answers

How to validate mysql database URI

I'm trying to integrate a Gem named blazer with my Rails application and I have to specify mysql database URL in blazer.yml file so that it can access data in staging and production environments. I believe the standard format to define MySQL…
Vasu
  • 69
  • 1
  • 1
  • 7
6
votes
1 answer

how to set mysql2 timezone option to remove query warning

I always get warning when use mysql2 do query /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 I did see…
Hunter
  • 121
  • 1
  • 7
6
votes
5 answers

How do I install mysql2 gem under Ruby 1.9.3? Works under 2.0.0

I'm having trouble installing the mysql2 gem on my machine. I have OS X 10.8 with the latest Xcode, and mySql installed via Homebrew. All rubies installed using the latest RVM. I can install mysql2 fine under ruby 2.0.0-p195 [~]$ rvm use 2.0.0 …
aselder
  • 71
  • 1
  • 3
6
votes
3 answers

Unable to install mysql2 gem OS X Mountain Lion

I'm new with RoR and I'm trying to install Mysql2 -v '0.3.11'. I have OS X Mountain Lion, rails 3.2.6 ,ruby 1.9.3. Below is the error I get. I looked everywhere and didn't find anything. $gem install mysql2 -v '0.3.11' Building native extensions. …
yabenjo
  • 61
  • 1
  • 2
6
votes
4 answers

Ruby mysql2 multiple statements in single query

I have an issue where I'm updating millions of rows in my DB, so rather than updating each one individually I want to join groups of ~1000 statements into a single query. I have enabled MULTI_STATEMENTS like so client = Mysql2::Client.new(:host =>…
Marklar
  • 1,056
  • 2
  • 13
  • 31