I need to setup ruby on rails with MySQL
I already have installed MYSQL
when I do Bundle install it shows following error.
Fetching mysql2 0.3.21
Installing mysql2 0.3.21 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
I am using Cent-os 8
anyone can help
Thanks
Run first this command gem 'mysql2', '~> 0.3.21' in terminal and when finish then try bundle again
Related
Getting below error message logged in the console while starting the server for an application created with mysql database.
Failed to load libmysql.dll from C:\RailsInstaller\Ruby2.3.0\lib\ruby\gems\2.3.0\gems\mysql2-0.4.7-x86-mingw32\vendor\libmysql.dll
Environment Details :
Window 7 64 bit
Rails 5.0.4
ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]
mysqld Ver 5.7.18 for Win64 on x86_64 (MySQL Community Server (GPL))
Post install message from mysql2 ruby gem received below message on the console.
You've installed the binary version of mysql2.
It was built using MySQL Connector/C version 6.1.10.
It's recommended to use the exact same version to avoid potential issues.
At the time of building this gem, the necessary DLL files were retrieved from:
http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-6.1.10-win32.zip
This gem *includes* vendor/libmysql.dll with redistribution notice in vendor/README.
I have tried the solution from here but did not work.
Any help appreciated, thanks in advance.
Downgrading mysql2 rubygem from version 0.4.7 to 0.3.21 solved my issue.
Below steps I followed
rails new blog -d mysql # created application with mysql as database
gem uninstall mysql2 #uninstalled mysql2-0.4.7
Gemfile :
gem 'mysql2', '0.3.21' #Gemfile changed mysql2 version to 0.3.21
bundle update mysql2 #installed mysql2-0.3.21 version
Just as an update to this thread, specifying the platform of the gem did the job for me;
gem uninstall mysql2
gem install mysql2 --platform=ruby
And here is my version details:
Windows OS
Ruby 2.5.0p0 (2017-12-25 revision 61468) [i386-mingw32]
Rails 5.1.6
Gemfile:
gem 'mysql2', '0.5.1'
I know may be this is a popular problem but i try many solutions and not get to finish
I try to install mysql in rails with
gem install mysql2
And I get the result
Building native extensions. This could take a while...
Successfully installed mysql2-0.3.18
1 gem installed
But when i try to execute the command
bundle show mysql2
I get
Could not find gem 'mysql2'.
All these command execute in my application root directory
What is the problem ?
bundle show lists the names and versions of all gems that are required by your Gemfile, so at first you should add mysql2 gem to it:
gem 'mysql2'
I am unable to install the "mysql2" gem on my CentOS linux machine.
I recently install mysql following the following tutorial: http://www.rackspace.com/knowledge_center/article/installing-mysql-server-on-centos
When I try to download "mysql2" gem I get the following log:
[root#vc2cmmka035538n ruby]# gem install mysql2
ERROR: Could not find a valid gem 'mysql2' (>= 0) in any repository
ERROR: Possible alternatives: mysql
Environment info:
Rails 3.2.3
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
gem -v 1.8.24
From their github page, quoted
This gem links against MySQL's libmysqlclient C shared library. You may need to install a package such as libmysqlclient-dev, mysql-devel, or other appropriate package for your system.
So, you might wanna install those packages first. Then you can even manually compile the gem if you still face the problem.
https://github.com/brianmario/mysql2
If mysql repo is disabled on your system, here is the link about installing them
http://dev.mysql.com/doc/mysql-repo-excerpt/5.6/en/linux-installation-yum-repo.html
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 have searched everywhere and no ones solutions solve my problem. I have built rails apps using SQLite but not MySQL. For this particular project, I need MySQL. When I attempt to boot the server I get an error, so I attempt to install the gems for MySQL and get another error. Does anyone have any insight? Thank you!
rails server
Could not find gem 'mysql2 (>= 0)' in any of the gem sources listed in your Gemfile.
sudo gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
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/mysql2-0.2.7 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/ext/mysql2/gem_make.out
I had this problem. You need to install the mysql gem with native extensions.
The line you're probably looking for is this:
$ ARCHFLAGS="-arch x86_64" gem install mysql2 --version '~> 0.2.7' -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Full write up on getting it going here: http://softwaregravy.com/mysql-on-os-x-rails-3-0-7/