mysql2

Database not being selected in rails project when attempting to rake db:migrate

倾然丶 夕夏残阳落幕 提交于 2019-12-05 04:04:31
Working with a rails app, having some manner of weird database / rake issues. When I execute: rake db:migrate I am getting the following error: Mysql2::Error: No database selected: SHOW TABLES (See full trace by running task with --trace) The trace isn't revealing much useful information. Can be seen here: http://pastebin.com/WdsguudC The config file looks right, and the user is getting logged in, or I would have gotten some kind of access error. The database exists, the user has correct permission, and I can access and manipulate it manually. I have done a bunch of googling, and haven't found

mysql2 gem 0.3.15 gives ASCII-8BIT with encoding set to “utf8”

℡╲_俬逩灬. 提交于 2019-12-05 00:24:52
I am using MySQL 5.1.71 with Rails 4.0.4 running on Ruby 2.0.0-p353 (via rbenv + ruby-build), with mysql2 gem 0.3.15. CentOS 6.5. In database.yml, encoding is set to "utf8" and adapter is "mysql2" for all environments. My tables are all using UTF-8, "DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci". In Ruby, Encoding::default_internal == Encoding::default_external == Encoding::UTF_8 . Any ideas on where else I can look to see why ActiveRecord still hands me ASCII-8BIT strings? I get UTF-8 on my Mac in development, but ASCII-8BIT in production on Linux. When I fire up a console and use mysql2

Rails 4, RSpec, MySQL2 default value error on first factory only

浪子不回头ぞ 提交于 2019-12-04 21:59:17
I'm upgrading from Rails 3.2.14 to Rails 4. When running RSpec on my test suite in my Rails 3 branch, all tests pass. On the Rails 4 branch, however, I'm getting an error on the first instance only of creating a factory. The error reads: ActiveRecord::StatementInvalid: Mysql2::Error: Field 'id' doesn't have a default value: INSERT INTO `of_of_measurements` (`aerobic_steps`, `calories`, `date`, `device_serial`, `distance`, `is_device_input`, `server_time`, `total_steps`, `user_id`) VALUES (15, 20, '2013-09-11 16:57:36', 'HJ1', 25.0, 0, '2013-09-11 16:57:36', 10, 1) My factory looks like this:

Start webrick in port 80 (mysql2 gem issue)

為{幸葍}努か 提交于 2019-12-04 18:48:44
问题 I am trying to get my webrick serve in port 80. I tried: rails server -p 80 but get a access denied. I later understood that using port 1-1024 needs a root permission, so I tried this instead sudo rails server -p 80 However, now i get a mysql2 error this time. Don't know what happened here. I tried to run: rails server -p 1025 and it's working fine, I think it's something about root and mysql2. Can anyone help? below is the error message in console: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7

Mysql2: close client connection

人盡茶涼 提交于 2019-12-04 07:35:40
I am using Mysql2 to query a database on ruby . I initialize the connection by: client = Mysql2::Client.new(:host => "localhost", :database => 'mydb', :username => "root") Once the query is done successfully, how can I close the client connection? If I do not close it, I soon reach the maximum number of possible open connections. Solution Thanks to @joonty: client.close Use client.close . From the docs : Mysql2::Client#close Immediately disconnect from the server, normally the garbage collector will disconnect automatically when a connection is no longer needed. Explicitly closing this will

Start webrick in port 80 (mysql2 gem issue)

随声附和 提交于 2019-12-03 12:15:46
I am trying to get my webrick serve in port 80. I tried: rails server -p 80 but get a access denied. I later understood that using port 1-1024 needs a root permission, so I tried this instead sudo rails server -p 80 However, now i get a mysql2 error this time. Don't know what happened here. I tried to run: rails server -p 1025 and it's working fine, I think it's something about root and mysql2. Can anyone help? below is the error message in console: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle, 9):

Rails error installing mysql2 (mysql2-0.3.20)

我怕爱的太早我们不能终老 提交于 2019-12-03 09:34:42
问题 I am trying to get a rails project up and running on my local machine. When I do bundle install Fetching mysql2 0.3.20 Installing mysql2 0.3.20 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/mac/.rvm/gems/ruby-2.3.1/gems/mysql2- 0.3.20/ext/mysql2 /Users/mac/.rvm/rubies/ruby-2.3.1/bin/ruby -r ./siteconf20180707-33936-1toblx7.rb extconf.rb checking for ruby/thread.h... yes checking for rb_thread_call_without_gvl() in ruby

Installing mysql2 gem on Mac os x Lion

孤街浪徒 提交于 2019-12-03 08:41:31
The other day I updated to Mac OSX Lion. It broke my rails install as I had to re complie mysql. While I have got that working reinstalling the mysql2 gem has become problematic. I was perviously running leopard so I am going from 32 to 64 bit. ~/code/rails/london (master)$ gem install mysql2 -- --with-mysql-dir=/usr/local/mysql Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /Users/stewartmatheson/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb --with-mysql-dir=/usr/local/mysql checking for rb_thread_blocking

Bundle install installs gems in ./mysql2 folder

跟風遠走 提交于 2019-12-03 07:54:42
问题 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 directory?? ruby-1.9.2-p180 [dev]:project.git$ bundle install NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01. Gem.source_index called from /Users/al/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.10/lib

Why does Rails 3 with Mysql2 Gem ActiveRecord::Base.connection.execute(sql) return Array not Hash?

南笙酒味 提交于 2019-12-03 04:30:50
问题 I'm in the process of upgrading an application to Rails 3. I've decided to go with the mysql2 gem. There's some legacy code in the app that makes calls like: results = ActiveRecord::Base.connection.execute(sql) In the 2.3.x version, it used results.each_hash do |row| ... But with gem mysql2, results is type Mysql2::Result , which has only an each method. Checked the docs and they specify results should be a hash keyed on field name. Great! But in fact, it is an Array , not a Hash . When I use