I am trying to setup mysql gem on ruby-1.9.3 installed with rvm. I want to set up the 'redmine'. To install mysql gem I used -->
sudo env ARCHFLAGS="-arch x86_64" gem install --no-rdoc --no-ri mysql -- --with-mysql-config=/usr/local/bin/mysql_config
When I issue --> RAILS_ENV=production rake db:migrate, I get
/Users/myth/.rvm/gems/ruby-1.9.3-p0#global/gems/bundler-1.1.2/lib/bundler/runtime.rb:211: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
cannot load such file -- mysql
However I have successfully deployed redmine1.3 on default ruby1.8.7 installation of OSX with installing mysql gem the very same way.
I want to work on the latest trunk with ruby-1.9.3
How can I resolve the issue? I have been searching the mailing list and found similar posts, however could not solve the problem.
I also struggled with this question. I could not get redmine working with mysql and ruby 1.9.3.
The answer is very easy and simple. For ruby 1.9.3 together with redmine you have to use the gem mysql2 !
In http://www.redmine.org/projects/redmine/wiki/RedmineUpgrade#Option-1-Downloaded-release-targz-or-zip-file it is also written to change the database adapter from mysql to mysql2.
So install gem install mysql2 and also keep sure to have a
database.yml with msql2 adapter:
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: redmine
encoding: utf8
Related
I am trying to learn web development with ruby on rails. I have been following a course on Lynda.com and my steps were as follows:
I installed Ruby + DevKit 2.4.4-1(x64)
I installed rails as in the command line as follows
gem install rails --version 5.0.0
I installed MySQL version 5.7.21
I installed mysql2 gem as follows
gem install mysql2
I installed Atom text editor
I created a new project rails new kudaweb -d mysql
I created the required databases in the MySQL shell
CREATE DATABASE kudaweb_development; and CREATE DATABASE kudaweb_test;
I then created a new user and granted all privileges as follows
GRANT ALL PRIVILEGES ON kudaweb_development.* TO 'rails_user'#'localhost' IDENTIFIED BY 'mypassword'
and i did this for the test database as well
I configured the database.yml file as follows:
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: rails_user
password: mypassword
host: localhost
I ran the following code to check if I had correctly configured the database
rails db:schema:dump
and I got the following error
C:\Users\Dj K-Staxx\Desktop\RUBY\kudaweb>rails db:schema:dump
rails aborted!
NameError: uninitialized constant Mysql2::Client::REMEMBER_OPTIONS
bin/rails:4:inrequire'
bin/rails:4:in <main>'
Tasks: TOP => db:schema:dump
I have no idea how to resolve this. I have searched the internet for solutions but to no avail. I am using windows 7 64bit and for the mysql2 gem I am using version 0.5.0
Seems like there may be some config issue between your 0.5.0 gem and mysql. It may not have built correctly. see: https://github.com/brianmario/mysql2/issues/954
Option 1: try reverting to 0.4.9 or 0.4.10 gem
set your gemfile to:
# ./Gemfile
...
gem 'mysql2', '0.4.9'
...
Option 2: try to compile the gem locally with c-connector
You may need a local C-connector to properly build the gem locally. see: https://www.digitalgyan.org/how-to-install-ruby-on-rails-mysql2-gem-on-windows-10/
that may be as simple as downloading the appropriate files from MySQL: https://dev.mysql.com/downloads/connector/c/
In either scenario, you may benefit from a quick script to test out connection (to rule out Rails as the problem).
require 'mysql2'
client = Mysql2::Client.new(host: "localhost", username: "rails_user", password: "mypassword")
update mysql2 gem in the Gemfile as:
gem 'mysql2', '~> 0.5.2'
I am trying to create a Rails application in windows with MySQL as the Database. I have created a rails app and it runs just as fine. But when I try to connect to the mySQL database I am getting weird errors, which I was unable to solve after hours of Googling and hunting around. Maybe I am performing a silly mistake, new to Rails and Ruby.
Here is how I proceeded in creating the app with MYSQL
In command prompt
rails new sample_app -d mysql
[success]
Opened a new command prompt window and
C:\sites\cd sample_app> rails -s
Now I get this error
Could not find gem mysq12 (>=0) in any of the gem sources listed in your Gemfile
Run bundle install to install missing gems
Note: I didn't get the error when I created my first rails app without using Mysql.
Next, I ran this command
gem install mysql2
And got this
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby1.8.7/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... no
checking for rb_hash_dup()... no
checking for rb_intern3()... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Next I ran this one -
bundle install
Closed all command prompt windows, opened a new one, moved to my app directory and typed
rails -s
Error:
could not find gem mysq12 (>=0) in any of the gem sources listed in your Gemfile
Run bundle install to install missing gems
Here are some information which I think will be useful
- Rails 3.0.9
- Ruby 1.8.7
- rake (10.1.0, 0.8.7)
- mysql (2.9.1 x86-mingw32)
- MySql 5.6 installed and running (I have created a DB and tables)
- OS: Windows 7 64bit
Here is how my database.yaml file looks like:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: sample_app_development
pool: 5
username: root
password: buiskol
host: localhost
Here is how the gemfile of the app looks like
source 'http://rubygems.org'
gem 'rails', '3.0.9'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2', '~> 2.9.1'
I think the problem is that my mysql2 gem is not properly installed. I am not sure where I am doing the mistake. Any help will be much appreciated.
Why are you using gem 'mysql2', '~> 2.9.1' instead of gem "mysql2", "~> 0.3.13"? According to this, there isn't any 2.9.1 version, maybe you meant 0.2.9 ? Otherwise, you're installing the wrong version of that gem, or the wrong gem with the right version.
You should use:
gem "mysql", "~> 2.9.1"
or
gem "mysql2", "~> 0.3.13"
in your gem file. Since there's no version 2.9.1 for mysql2, correct the typo and try again
I'm on OSX 10.7.5
I'm setting up an existing Rails 3 app
I've got the 64-bit dmg package of MySQL (v5.5.28) installed
I've installed the mysql2 gem (v0.3.11) as part of the app bundle
Whenever i try to load the rails env (raking, loading console, etc.), I get this:
rake aborted!
dlopen(/Users/daretorant/.rvm/gems/ruby-1.9.3-p194#amp/bundler/gems/mysql2-f4d004ac5194/lib/mysql2/mysql2.bundle, 9): Symbol not found: _rb_prohibit_interrupt
Referenced from: /Users/daretorant/.rvm/gems/ruby-1.9.3-p194#amp/bundler/gems/mysql2-f4d004ac5194/lib/mysql2/mysql2.bundle
Expected in: flat namespace
in /Users/daretorant/.rvm/gems/ruby-1.9.3-p194#amp/bundler/gems/mysql2-f4d004ac5194/lib/mysql2/mysql2.bundle - /Users/daretorant/.rvm/gems/ruby-1.9.3-p194#amp/bundler/gems/mysql2-f4d004ac5194/lib/mysql2/mysql2.bundle
/Users/daretorant/.rvm/gems/ruby-1.9.3-p194#amp/bundler/gems/mysql2-f4d004ac5194/lib/mysql2.rb:9:in require'
/Users/daretorant/.rvm/gems/ruby-1.9.3-p194#amp/bundler/gems/mysql2-f4d004ac5194/lib/mysql2.rb:9:in'
.........
Things I've tried:
other versions of mysql2
fresh install of mysql itself
cleaning my gemset
cleaning rvm
pulling hair out
Help?
I have just run into this issue. What had helped me was installing the 64bit version of the mysql2 gem, like this:
$ env ARCHFLAGS="-arch x86_64" gem install mysql2
I am running this on a Windows 7 (64 bit) machine. I installed RoR using the one-click installer. I've updated my database.yml file to use mysql2:
development:
adapter: mysql2
encoding: utf8
database: blog_development
pool: 5
username: root
password:
socket: /tmp/mysql.sock
test:
adapter: mysql2
encoding: utf8
database: blog_test
pool: 5
username: root
password:
socket: /tmp/mysql.sock
production:
adapter: mysql2
encoding: utf8
database: blog_production
pool: 5
username: root
password:
socket: /tmp/mysql.sock
I added this line to my Gemfile (per the tutorial video):
gem 'mysql2', :group => :production
Then:
gem install mysql2
which succeeds. Then:
bundle install
Which also succeeds, but mysql2 is not listed.
Then:
rake db:create
which gives this error:
"rake aborted!
Please install the mysql2 adapter: gem install activerecord-mysql2-adapter (my
sql2 is not part of the bundle. Add it to Gemfile.)
Tasks: TOP => db:create
(See full trace by running task with --trace)"
bundle show mysql2
Gives this error: "Could not find gem 'mysql2' in the current bundle."
What am I missing to get mysql2 going?
Run bundle install before rake db:create (after the gem install mysql2)
Go to your app
Open Gemfile
Add this line
gem 'mysql2'
Similar issue was resolved for me after
creation of libmysql.lib file per https://github.com/brianmario/mysql2/issues/486 and using it to install/compile native gems (lib resided in directory used for "--with-mysql-lib="$mysql top_path/lib"" gem installation)
putting libmysql.dll to ruby_top bin folder
installing both mysql and mysql2 gems (was getting exactly the same error with just mysql2 gem installed, though database.yml had "adapter = mysql2" everywhere).
After all that mysql2 appeared in list of gems after command "bundle install", I was able to run "rake db:create" successfully, started redmine x64 windows on x64 ruby 2.0 with x64 mysql on webrick, going on with configuring on some production server.
===============
An update
I have to precise that besides installing both mysql and mysql2 I created file Gemfile.local in redmine application top directory which probably made the trick with bundler.
So I would recommend to replace the last step with:
installing mysql2 gem
creating the file Gemfile.local in application top directory where
you list local gems to be included to your bundle.
I saw another answer that recommends to add mysql2 gem to Gemfile, but for me mysql2 was already included in Gemfile but has appeared in bundler output after adding to Gemfile.local only.
I'm leaving both solutions if I'm wrong and the trick was done by mysql gem installed together with mysql2, unfortunatelly I cannot remove/reinstall all from scratch now to test that for sure, I will update when I'm able to do so, hope all this will save some time to someone.
My Gemfile.local file contents is:
---8<---
gem "mysql2", "~> 0.3.11"
gem "eventmachine"
gem "thin"
---8<---
I successfully installed MySql x86_64 in Snow Leopard and Ruby and Ruby Gems seems to be installed properly:
$ which mysql
/usr/local/mysql/bin/mysql
$ which ruby
/usr/bin/ruby
$ which gem
/usr/bin/gem
$ mysql
Your MySQL connection id is 404
Server version: 5.1.37 MySQL Community Server (GPL)
$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
$ gem -v
1.3.5
Unfortunatly I get an error installing mysql gem:
$ sudo gem update --system
...
$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-mysql-config=/usr/local/mysql/bin/mysql_config
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.
I think you should try to uninstall the old mysql gem first before recompiling
sudo gem uninstall mysql
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Installing the Xcode that's bundled with the Snow Leopard fixed the problem.
For me, it was adding the UNIX Tools option (if I recalled the name accurately), which include the headers. When I installed XCode originally, I didn't include this component because I didn't think that I would be writing UNIX code. Little did I know...
If you've installed MySQL 5 using MacPorts, then use the command:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5
I had this problem when I updated to Lion. In this case, I when to the app store and downloaded the latest Xcode. Then I uninstalled and reinstalled the database.
The issue had to do with a broken link during the update. Ruby likes to be in /System while Apple places ruby in /Developer.
was stuck with same problem:
Tried most of the solution's: At the end
Edit the app/config/database.yml, change the adapter to mysql2
production:
adapter: mysql2
database: commissi_production
username: root
password: root
host: localhost
& run on terminal
gem install activerecord-mysql2-adapter
Solved the problem.