error setting up MySQL database for RoR - mysql

I'm new to Ruby on Rails and am having trouble setting up my first MySQL database.
I followed the instructions on here: https://gorails.com/setup/osx/10.12-sierra
And I reached the very end where it asks you to run "rake db:create". When I execute this in the terminal, I get the following error:
MacBook-Air-de-myusername% rake db:create
rake aborted!
cannot load such file -- bundler/setup
/Users/myusername/splash/config/boot.rb:3:in `<top (required)>'
/Users/myusername/splash/config/application.rb:1:in `require_relative'
/Users/myusername/splash/config/application.rb:1:in `<top (required)>'
/Users/myusername/splash/Rakefile:4:in `require_relative'
/Users/myusername/splash/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
Can anyone advise on what is happening? I know that I have "cd"-ed into the correct directory, so that can't be it.

Install bundler gem and run bundle install:
$ gem install bundler
$ bundle install
Now run rake again:
$ rake db:create
If that doesn't work, then run the complete command:
$ bundle exec rake db:create
To understand more about bundle command, check this question.

Run:
gem install bundler
bundle install
bundle exec rake db:create

I think you are in incorrect folder.
try cd splash
then run following command:
bundle install
bundle exec rake db:create

Related

LoadError: cannot load such file -- mysql2/mysql2 - on rake db:create

When i run rake db:create, I get this error:
LoadError: cannot load such file -- mysql2/mysql2
/Users/vitorqueiroz/dev/pipeline/config/application.rb:10:in `<top (required)>'
/Users/vitorqueiroz/dev/pipeline/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
I had to mannualy install mysql2 gem because the gemfile specifies the version '0.3.20'
I ran
gem install mysql2 -v '0.3.20' -- --srcdir=/usr/local/include/mysql
Bundle install runs fine, and says everything is installed.
bundle list mysql2 evaluates to:
/Users/vitorqueiroz/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/mysql2-0.3.20
--
Any alternatives?
You can try
bundle exec rake db:create
to be sure that bundled gems are loaded.
https://bundler.io/man/bundle-exec.1.html

Can't rake:db migrate - Keep getting a 'rake aborted! load error' [duplicate]

This question already has answers here:
Ruby Bundle Symbol not found: _SSLv2_client_method (LoadError)
(10 answers)
Closed 8 years ago.
I installed MySQL using Homebrew (brew install mysql), and then ran $ gem install mysql2 . I'm on a Mac running OSX 10.9.4.
I changed directories into the root of my app, and then try to run the rake db:migrate command, and got this error:
Levine_iMac$ rake db:migrate
rake aborted!
LoadError: dlopen(/Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle, 9): Symbol not found: _SSLv2_client_method
Referenced from: /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle
Expected in: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
in /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle - /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:3:in require'
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:3:in <top (required)>'
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/Rakefile:4:in <top (required)>'
(See full trace by running task with --trace)
Levine_iMac$
I tried adding something to my .bash_profile, as described here, but that did not work.
I tried a sudo command as described here, but that did not work.
I then tried updating my Ruby version from 2.1.1.. to 2.1.2.., and now I am getting this error when I run rake:db migrate
Levine_iMac$ rake db:migrate
rake aborted! cannot load such file -- bundler/setup /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/boot.rb:4:in '<top (required)>' /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:1:in '<top (required)>' /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/Rakefile:4:in '<top (required)>' (See full trace by running task with --trace) Levine_iMac$ bundle install rbenv: bundle: command not found The 'bundle' command exists in these Ruby versions:
2.1.1
Levine_iMac$
Any ideas on how to remedy this? Thanks.
Well, what are you exactly expecting to happen when you run rake db:migrate? Is some next step going to materialize for you? If you are able to answer this question, you will understand why what you're doing doesn't make sense.
I'll elaborate:
rake db:migrate only works in the context of an existing rails application. Running 'gem install mysql2' will get that library for you on your computer (this command is executed by itself, it doesn't actually have anything to do with Rails itself, or need a Rails app for context). So, there's no linear connection between the two.
rails new myapp
add 'gem mysql2' in the Gemfile
bundle
rake db:create
Or, alternatively:
rails new myapp -d mysql

Why is my rake db:migrate failing to respond?

I tried typing in rake db:migrate to create a migration, but my rake is aborted and giving me this statement. Could you please explain why this is happening?
Muhammeds-MacBook-Pro:simple_cms muhammedz786$ rake db:migrate
rake aborted!
dlopen(/Users/muhammedz786/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/mysql2-0.3.14/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Users/muhammedz786/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/mysql2-0.3.14/mysql2/mysql2.bundle
Reason: image not found - /Users/muhammedz786/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/mysql2-0.3.14/mysql2/mysql2.bundle
/Users/muhammedz786/rails_application/simple_cms/config/application.rb:7:in `<top (required)>'
/Users/muhammedz786/rails_application/simple_cms/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
your mysql package not install properly for that give command
sudo apt-get install mysql-server mysql-common mysql-client
if this is not work install this
sudo apt-get install libmysql-ruby libmysqlclient-dev
From your question I see you are on a Macintosh. Therefore, try the following:
Run mysql_install_db in the terminal
Run mysql.server start in the terminal
If that doesn't work checkout Installing mysql2 gem for Ruby on Rails with Mac OSX 10.6

Ruby on Rails : MySQL client library issue when trying to create database

I have a rails application which is running on Rails 3.2.8 and Ruby 1.9.3.I am also using Mysql server as database.
When I run rake db:migrate, I get the following error:
rake aborted!
Incorrect MySQL client library version! This gem was compiled for 6.0.0 but the
client library is 5.5.34.
C:/Rails SampleApps/MyAppName/config/application.rb:7:in `<top (required)>'
C:/Rails SampleApps/MyAppName/Rakefile:5:in `require'
C:/Rails SampleApps/MyAppName/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
How do I solve this issue?
Any help is appreciated..
Since you are using windows, you have two options to solve this :
Either use 2.8.1 version of mysql gem by writing
gem 'mysql', '2.8.1' #in your gemfile
run
bundle install
OR
Simply use mysql2 gem
gem 'mysql2'
and put the libmysql.dll file in installed MySQL bin directory with the one which you can get from the below link in location lib/libmysql.dll from
http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick
gem 'mysql2' ## gemfile
rm Gemfile.lock
bundle install
rake db:drop && rake db:create

Rake assets:precompile

C:\Sites\dtr-payroll>rake assets:precompile
rake aborted!
You have already activated rake 10.0.4, but your Gemfile requires rake 10.0.3. Using bundle exec may solve this.
C:/Sites/dtr-payroll/config/boot.rb:6:in `<top (required)>'
C:/Sites/dtr-payroll/config/application.rb:1:in `<top (required)>'
C:/Sites/dtr-payroll/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
you should first delete your Gemfile.lock file and bundle install again and then use
rake assets:precompile
this is because you have activated rake 10.0.4 but in your Gemfile.lock file it is rake 10.0.3 so either you changed it or delete Gemfile.lock file.
Update your rake to 10.0.4 via
bundle update rake
that would fix it
please try
bundle exec rake assets:precompile
you should google it first
you can use bundle exec rake assets:precompile
if you update the database migrate,you can use:
bundle exec rake db:migrate