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
5
votes
3 answers

Bundler ignoring install of MySQL2 gem when run on my 'production' server

I'm attempting to install the 'mysql2' gem on my production server using Capistrano. I want to use SQLite in development, and MySQL in production. I develop on a Windows 7 machine, and production is using Ubuntu. When I run bundle install on my…
greggannicott
  • 885
  • 2
  • 9
  • 22
5
votes
4 answers

how do I perform transactions with ruby mysql2

I've started using mysql2 gem. I'm trying to figure out a few basic things - one of them is how to explicitly perform transactions (for batch operations, like multiple INSERT/UPDATE queries). In the old ruby-mysql, this was my approach: client =…
sa125
  • 28,121
  • 38
  • 111
  • 153
5
votes
2 answers

LOAD DATA LOCAL INFILE causes Malformed packet error with mysql2 gem

I'm trying to issue a LOAD DATA LOCAL INFILE query to load some CSV data into a table using the mysql2 gem (0.3.11) under rails 3.1.1: class Foo < ActiveRecord::Base def self.load_csv query = "LOAD DATA LOCAL INFILE 'test/foo.csv' REPLACE INTO…
Thilo
  • 17,565
  • 5
  • 68
  • 84
5
votes
5 answers

Mysql2::Error (Access denied for user 'root'@'localhost' (using password: NO)):

Just setup a new rails 3.1.3 app using mysql (mysql2 gem) on CentOS 5 server / apache / passenger... I have correctly setup a database and a user for that database and I have added the login and info into my database.yml file... I can generate…
webmaster_sean
  • 942
  • 4
  • 13
  • 23
5
votes
5 answers

-Fatal- failed to allocate memory - Rails 3.1 and Mysql2 Gem

I'm having a strange problem with the latest 'mysql2' gem and Rails 3.1 I can run mysql fine from the IRB when I include the gem, but with rails whenever I attempt to save to the database in the console, or even load up the page when the server…
redroot
  • 614
  • 2
  • 7
  • 17
5
votes
2 answers

Bundle install installs gems in ./mysql2 folder

I recently upgraded mysql on my machine. As a result I'm attempting to update my mysql2 gem accordingly. In the process of doing that, I run "bundle install", and for some reason all of the gems in my Gemfile are getting installed in a ./mysql2…
Sly
  • 743
  • 13
  • 38
5
votes
1 answer

Too many connections Nodejs + mysql2/promise

I am working in a proyect with nodejs + mysql2 and some times I got the error Too many connections. My connection: import {createPool, Pool} from 'mysql2/promise'; export async function connect(): Promise < any > { const connection: Pool = await…
5
votes
3 answers

node mysql2 can't access update results

I'm doing a simple UPDATE with mysql2 : UPDATE table1 SET table1.value1 = ?, table1.value2 = ? WHERE user_id = ( SELECT user_id FROM user WHERE company_id = ? ) table1 is related to the user table by user_id, but…
hamncheez
  • 709
  • 12
  • 22
5
votes
1 answer

how to solve 'connection is still waiting for a result' error with em_mysql2

I'm using activerecord with em_mysql2 under Goliath (eventmachine). The oddest thing is happening with my User model. When I do a POST to /users the first time, it all works just find as expected. When I do a second POST I get an…
radixhound
  • 2,190
  • 2
  • 18
  • 23
5
votes
1 answer

`require': cannot load such file -- mysql2/mysql2

After having difficulty but succeeding in installing mysql2 v 0.4.2 using gem install mysql2 -v '0.4.2' -- --srcdir=/usr/local/mysql/include I am now stuck with the following error when running bundle exec rails s `require': cannot load such file…
Julien
  • 140
  • 1
  • 9
5
votes
1 answer

mysql2 inserting values nodejs

I have this post request app.post("/msg", (req, res) => { console.log(req.body) connection.query('INSERT INTO plans (topic, notes, resources) VALUES (?)', [req.body.topic, req.body.note, req.body.resource],(error, results) => { if…
Salim Abubakar
  • 53
  • 1
  • 1
  • 3
5
votes
1 answer

MYSQL: Invalid JSON text: "Invalid escape character in string."

I'm trying to insert a JSON object into a MySQL JSON column and I'm getting: Invalid JSON text: "Invalid escape character in string." The offending character is the \n in this part of the object: "summary":"Summary of Qualifications:\nAccomplished…
James Gentes
  • 7,528
  • 7
  • 44
  • 64
5
votes
1 answer

Mysql2 gem casting datetime objects from remote db in local (server) time

I've been over and over the documentation of the (otherwise) excellent Mysql2 gem. I have a production Rails app hosted on a server running in UTC. The app's config.time_zone is set to "Eastern Time (US & Canada)." We have an internal MS…
Thom
  • 73
  • 7
5
votes
1 answer

Mysql2::Error Access denied for user 'root'@'localhost' (using password: NO) ruby on rails

I installed Ruby on Rails 4.2 on Ubuntu successfully and am using MySQL as my database but when I want to see the new app I created on the browser using localhost:3000 I get this error message: Mysql2::Error Access denied for user…
user3266023
  • 123
  • 4
  • 15
5
votes
3 answers

How can I iterate through an array in rails view?

I did a query in MySql but is working in Rails and mysql2 gem. Here is the information: http://sqlfiddle.com/#!2/9adb8/6 The query is working fine without problems and showing this result: UNIT V1 A1 N1 V2 A2 N2 V3 A3 N3 V4 A4 N4 …
Carlos Morales
  • 1,137
  • 3
  • 15
  • 38