无法在 Ubuntu 服务器上安装 Mysql gem

Can not install Mysql gem on Ubuntu server

我在我的 gem 文件中添加了 mysql gem 但是当我 运行 bundle install 它向我显示以下错误。

An error occurred while installing mysql (2.9.1), and Bundler cannot continue. Make sure that `gem install mysql -v '2.9.1'` succeeds before bundling.

我在我的 Ubuntu machine.I 上安装这个 gem 我正在使用 rails 版本 4.2.0 和 ruby 2.1.7.I 正在解释下面的 mu gem 文件。

Gemfile:

source 'https://rubygems.org'
ruby '2.1.7'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.18.2'
gem 'mysql', '~> 2.9.1'
gem 'postgres_ext', '~> 2.4.1'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails', '~> 4.0.3'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks', '~> 2.5.3'
gem 'jquery-turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'bootstrap-sass', '~> 3.3.4'
gem 'font-awesome-sass', '~> 4.2.0'

gem 'devise', '~> 3.4.1'
gem 'devise_invitable', '~> 1.5.0'
gem 'omniauth-facebook', '~> 2.0'
gem 'omniauth-google-oauth2', '~> 0.2.6'
gem 'simple_form', '~> 3.1.0'
gem 'cancancan', '~> 1.9.2'

gem 'will_paginate', '~> 3.0.7'
gem 'will_paginate-bootstrap', '~> 1.0.1'

# Use this only for admin related filters
gem 'ransack', '~> 1.5.1'

# Enums: single & multi value, integrates with ActiveRecord, simple_form
gem 'enumerize', '~> 0.9.0'

# Image processing
gem 'mini_magick', '~> 4.0.1'

# File uploads
gem 'fog', '~> 1.27' #, require: 'fog/aws/storage'
gem 'carrierwave', '~> 0.10.0'

# Phone number validation
gem 'phonelib', '~> 0.4.0'

# Nested forms
gem 'cocoon', '~> 1.2.6'

gem 'combined_time_select', '~> 1.0.1'

# For file uploads
gem 'jquery-fileupload-rails', '~> 0.4.4'

# jquery light gallery
gem 'light_gallery_rails', git: 'https://github.com/stNicolaas/light-gallery-rails.git'

# Background processing
gem 'que', '~> 0.9.2'

gem 'rails-timeago', '~> 2.11.1'

gem 'listjs-rails', '~> 1.1.1'

gem 'selectize-rails', '~> 0.12.0'
gem 'client_side_validations', git: 'https://github.com/DavyJonesLocker/client_side_validations.git'
gem 'client_side_validations-simple_form', git: 'https://github.com/DavyJonesLocker/client_side_validations-simple_form.git'

gem 'validate_url', '~> 1.0.0'

gem 'friendly_id', '~> 5.1.0'

gem 'bootstrap-slider-rails', git: 'https://github.com/stationkeeping/bootstrap-slider-rails.git'

gem 'recaptcha', '~> 0.4.0', require: 'recaptcha/rails'

gem 'google-analytics-turbolinks', '~> 0.0.4'

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console
    gem 'byebug'

    # Access an IRB console on exception pages or by using <%= console %> in views
    gem 'web-console', '~> 2.0'

    # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
    gem 'spring'

    # Exceute 'rspec' on command line to run tests
    gem 'rspec-rails', '~> 3.0'
    gem 'rspec-its'

    # Fixtures replacement
    gem "factory_girl_rails", "~> 4.0"

    # Fake data
    gem "faker"

    # rails environment variables
    gem 'figaro', '~> 1.1.1'
end

group :development do
    # Annotate models
    gem "annotate", "~> 2.6.5"
end

group :test do
    # See http://robots.thoughtbot.com/how-we-test-rails-applications > Database Cleaner
    gem 'database_cleaner', "~> 1.3.0"

    gem 'capybara', "~> 2.4.0"
end

group :production do
    gem 'mandrill_dm', '~> 1.2.0'
end

请帮我解决这个错误。

尝试

sudo apt-get install libmysqlclient-dev 

如果这没有帮助,请在此处粘贴您遇到的错误。