NoMethodError: undefined method `init' for Mysql:Class in rails after updating to ubuntu 12.04 - mysql

After I updated to ubuntu 12.10, I started getting this error:
NoMethodError: undefined method `init' for Mysql:Class
I am using the mysql adapter.

% gem install mysql
solved the problem. Note that this gem was installed already even before I updated the ubuntu version but somehow the setup got messed up in the update.

Related

Rails5 jruby not able to start

Not able to start rails5 with jruby, getting the following error.
gavinyap#gavin-ubuntu  ~/Development/rails5app  rails s
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from require at bin/rails:4)
Bundler::GemRequireError: There was an error while trying to load the gem 'activerecord-jdbcmysql-adapter'.
Gem Load Error is: uninitialized constant ActiveRecord::ConnectionAdapters::Column::Format
Backtrace for gem load error is:
/home/gavinyap/.rvm/gems/jruby-9.1.2.0/gems/activerecord-jdbc-adapter-1.3.20/lib/arjdbc/jdbc/type_cast.rb:13:in `<module:TypeCast>'
/home/gavinyap/.rvm/gems/jruby-9.1.2.0/gems/activerecord-jdbc-adapter-1.3.20/lib/arjdbc/jdbc/type_cast.rb:7:in `<module:Jdbc>'
/home/gavinyap/.rvm/gems/jruby-9.1.2.0/gems/activerecord-jdbc-adapter-1.3.20/lib/arjdbc/jdbc/type_cast.rb:4:in `< module:ConnectionAdapters>'
/home/gavinyap/.rvm/gems/jruby-9.1.2.0/gems/activerecord-jdbc-adapter-1.3.20/lib/arjdbc/jdbc/type_cast.rb:3:in `<top>'
/home/gavinyap/.rvm/gems/jruby-9.1.2.0/gems/activerecord-jdbc-adapter-1.3.20/lib/arjdbc/jdbc/column.rb:1:in `singleton cla
Versions of Jruby and Rails
jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f
OpenJDK 64-Bit Server
VM 25.91-b14 on 1.8.0_91-8u91-b14-0ubuntu4~16.04.1-b14 +jit [linux-x86_64]
Rails 5.0.0
The ActiveRecord JDBC gem has not been updated for Rails 5. Checking the project in GitHub shows some development activity early this year but there is no indication when a new gem will be released for Rails 5.
add gem 'activerecord-jdbcmysql-adapter', '~> 5.0.pre1' to your gemfile

Django : How to install mysql

I want to use mysql with django but I have problems
I tried this with pip :
(env) C:\mat20>pip install MySQL-python==2.7.1
and I have the error:
No distributions matching the version for MySQL-python==2.7.1
after I tried :
(env) C:\mat20>pip install MySQL-python
and I have the error :
error: Unable to find vcvarsall.bat
What is the problem ?
You can solve this error error: Unable to find vcvarsall.bat by
mingw
or try Install c++ compiler here

NameError: cannot load Java class com.mysql.jdbc.Driver

I'm using JRuby 1.7.2, along with DataMapper, and I'm getting an error I can't find an answer to.
I'm just testing out DataMapper along with MySQL 5.5 to see if it will run fine when I build around it. Here's the file I'm testing:
require "data_mapper"
require "keys"
DataMapper.setup(:default, "mysql://#{$user}:#{$pass}#localhost/test_db")
And when I run this, I get the error:
NameError: cannot load Java class com.mysql.jdbc.Driver
And it points to the DataMapper.setup line.
My Gemfile should be alright:
source :rubygems
gem "sinatra"
gem "trinidad"
gem "data_mapper"
# do a `sudo apt-get install libmysqlclient-dev` first
gem "dm-mysql-adapter"
gem "jdbc-mysql"
Is there anything I'm missing? I have MySQL set up with a user/pass locally already.
This is a common error when running JDBC clients for MySQL. You need to make sure you have mysql-connector-java-bin.jar on the classpath. You can download it from here.
I'm using Rails 3.2.9 and to solve the problem I added this to my application.rb
if defined? JRUBY_VERSION
require 'jdbc/mysql'
Jdbc::MySQL.load_driver
end
actually, the correct answer is to work-around an incompatibility between 5.1.13 and 5.1.22 !
jdbc-mysql gem already contains the mysql-connector.jar it just ain't auto-loading anymore :
https://github.com/jruby/activerecord-jdbc-adapter/tree/master/jdbc-mysql (read the README)
you can also force the driver to auto-load using a Java system property e.g. from a cmd line :
jruby -J-Darjdbc.mysql.autoload=true -S rake ...
I had the same error when trying to use a mysql database from jruby/rails4. In my case this line was missing from ./Gemfile:
gem 'jdbc-mysql'

can't run migration

I run
rake db:create
and getting strange error
rake aborted!
126: ═х эрщфхэ єърчрээ√щ ьюфєы№. - C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-
0.3.11-x86-mingw32/lib/mysql2/1.9/mysql2.so
I tried to reinstall bundler.
Is it gem problem ?
To solve this problem, reference to the following link:
http://maxivak.com/installing-mysql2-gem-on-ruby-1-9-2-and-rails-3-0-5-on-windows/
You need to include mysql-connector through the Rails DevKit.

Help with MySQL gem on OSX

I'm trying to get the mysql gem working on OSX 10.5.6, and feeling stymied.
% gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while...
Successfully installed mysql-2.7
1 gem installed
% irb -rubygems -rmysql
irb> Mysql.init
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: /Users/rampion/.gem/gems/mysql-2.7/lib/mysql.bundle
Expected in: dynamic lookup
dyld: Symbol not found: _mysql_init
Referenced from: /Users/rampion/.gem/gems/mysql-2.7/lib/mysql.bundle
Expected in: dynamic lookup
zsh: trace trap irb -rubygems -rmysql
%
I'm using the default install of ruby 1.8.6.
I'm using a 64-bit version of MySQL 5.0.77. mysqld is running and I can use the mysql shell, so I suspect my issue is with mysql.gem, though I'm by no means certain.
Can anyone offer any advice?
Ok. So the solution turned out to be I needed to be runing the 32-bit version of MySQL 5.0.77 in order for mysql.gem to work.