I want to use MySQL in ROR.
I add gem in my Gem file.
gem mysql2
and then I run a command
gem install mysql2
It gives me following error
"could not find a valid gem '0.3.13' <> =0> in any repository"
Please anybody tell me how can i use MySQL for ROR application
Thanks
I think your syntax in your Gemfile is missing quote marks:
gem 'mysql'
and then your commandline call to install it should instead be:
bundle install
Related
Whenever i run my rails server command on my command prompt it gives me the following error:
Since i am new to the Rails, I don't know much about it.
Guide me with the solution if possible..
I am using rails 5 on windows OS
Specified 'mysql2' for database adapter, but the gem is not loaded. Add gem 'mysql2' to your Gemfile
As your error says please add mysql2 in your Gemfile
# Gemfile
gem 'mysql2'
Also make sure you have mysql installed
The answer to your question is in the error message. You're using mysql2 as your database adaptor, but the gem isn't available.
add:
gem 'mysql2'
to your gemfile, then run bundle update from your project folder to install the missing gem.
You need to add
gem 'mysql'
in your Gemfile.
If its added then run command bundle install to install it. And check whether its installed successfully or not then restart server.
Also check your gem version with your Rails version.
Hello everyone I am new to rails I am following lynda tutorial and I am trying to install mysql2 but the error is showing I have look on various page of stack overflow but was not able to resolve it.My Error is
ERROR: Could not find a valid gem 'mysql2' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - no such name (https://api.rubygems.org/latest_specs.4.8.gz)
On Windows, you need to use the following:
Download C-Connector & unzip to a non-spaced path on your system
Install the gem referencing the new path:
gem install mysql2 --platform=ruby -- --with-mysql-dir="C:/path/to/your/c-connector/install/no/spaces"
This should install the gem, allowing you to proceed with your other installation.
--
The reason this has to be done on Windows is due to the fact that the mysql2 gem requires an external set of dependencies (the c-connector plugin), which Windows does not have installed by default.
Linux users can use apt-get, and Mac users brew to get the dependencies; Windows users have to download it themselves.
If you follow the steps above, you should get the mysql2 gem installed.
I think there is some typos in your gemfile, Check if you have type correct version mentioned in the tutorial. mysql gem should look like below.
gem 'mysql2', '~> 0.3.11'
I am installing mysql gem for my application but i have an error
please any one tell me how can i install MySQL gem
gem install mysql2 -v '0.3.11'. Its a generic error.
I am new to Ruby, previously I installed an older Ruby and gem versions and I create one sample project.
Now I...
uninstall the Ruby and all using uninstall program via control panel.
install new versions of ruby and all.
run the server - it throws a lot of errors.
I solved some problems but I am not able to solve the Gem::LoadError and rake db:migrate errors.
Please help me. Thanks in advance.
Try to add gem sqlite3 into your Gemfile and then run bundle in console.
It should look something like this
Gemfile
source 'https://rubygems.org'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
I used rvm to install jruby (1.5.6) and installed all my gems just fine. I can run simple rails tasks like
script/runner 'puts 1'
and the output is fine. AS SOON as I hit the database I get an error. I have uninstalled/reinstalled the activerecord-jdbcmysql-adapter gem, Jruby, rvm, JAVA_JDK. I have set the JRUBY_HOME and JAVA_HOME correctly, but it seems like nothing works.
Any thoughts?
As far as I know, I have Java JDK 1.6.0 and 1.5.0 installed. IT is currently pointed to 1.6.0. But since all the other gems installed correctly, I am assuming this is something else entirely.
I am on EC2 with Ubuntu 10.04 (64 bit)
Ruby 1.9.2 with RVM works great!
nohup: ignoring input
/opt/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:76:in establish_connection': Please install the jdbcmysql adapter:gem install activerecord-jdbcmysql-adapter(no such file to load -- active_record/connection_adapters/jdbcmysql_adapter) (RuntimeError)
from /opt/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:60:inestablish_connection'
from /opt/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in establish_connection'
from /opt/jruby/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:438:ininitialize_database'
from /opt/jruby/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:141:in process'
from /opt/jruby/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:113:inrun'
from /home/tesmar/rails/statsheet/config/environment.rb:19
from /home/tesmar/rails/statsheet/config/environment.rb:39:in require'
from /opt/jruby/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/runner.rb:39
from /opt/jruby/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/runner.rb:3:inrequire'
from script/runner:3
As the error message says, you need to install the activerecord-jdbcmysql-adapter gem.
It is possible that your execution environment is different from your rvm environment. I've seen this happen with IDEs such as NetBeans.
How do your gemfile look like?
Mine looks like this and work:
source 'http://rubygems.org'
gem 'rails', '3.0.4'
platforms :ruby do
gem 'mysql2'
end
platforms :jruby do
gem 'activerecord-jdbc-adapter'
gem 'jdbc-mysql', :require => false
end
If you are going back and forth between jRuby and MRI, you can add something like this to your Gemfile too:
if defined?(JRUBY_VERSION)
gem 'jdbc-mysql'
gem 'activerecord-jdbc-adapter'
gem 'activerecord-jdbcmysql-adapter'
gem 'warbler'
else
gem 'mysql'
gem 'mongrel'
end
Then, in your database.yml add something like this:
development:
adapter: <%= defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql' %>
I figured it out. I had to download the JAR file, after copying manually all the rb files into the active record gem (the rb files from the activerecord-jdbcmysql and activerecord-jdbc gems). I then put the JAR file in the /opt/jruby/lib directory and it works! Woohoo!