Ruby on rails can';t使用gem安装mysql2

Ruby on rails can';t使用gem安装mysql2,ruby-on-rails,rubygems,Ruby On Rails,Rubygems,我正在尝试使用rails创建一个以mysql作为数据库的项目 我使用以下命令: gem install mysql2 我在命令行中得到以下结果: Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /home/sample/.rbenv/versions/2.2

我正在尝试使用rails创建一个以mysql作为数据库的项目

我使用以下命令:

 gem install mysql2
我在命令行中得到以下结果:

Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

    /home/sample/.rbenv/versions/2.2.3/bin/ruby -r ./siteconf20170316-5426-f6rn3k.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for rb_big_cmp()... yes
checking for mysql_query() in -lmysqlclient... no
-----
mysql client is missing. You may need to 'apt-get install libmysqlclient-dev' or 'yum install mysql-devel', and try again.
-----
*** 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.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/sample/.rbenv/versions/2.2.3/bin/$(RUBY_BASE_NAME)
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-mysql-config
    --without-mysql-config
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-mysqlclientlib
    --without-mysqlclientlib

extconf failed, exit code 1

Gem files will remain installed in /home/sample/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mysql2-0.4.5 for inspection.
Results logged to /home/sample/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0-static/mysql2-0.4.5/gem_make.out
另外,当提到mysql客户端丢失时,我尝试安装提到的模块,但没有成功。 有人能提供解决方案吗

sudo apt-get install libmysqlclient-dev
然后

然后


请安装
apt get install libmysqlclient dev
,然后在尝试安装
mysql
gemyah之后,我收到以下错误:E:无法打开锁文件/var/lib/dpkg/lock-open(13:权限被拒绝)E:无法锁定管理目录(/var/lib/dpkg/),你是root用户吗?用
sudo
sudo
尝试该命令意味着
super user do
请安装
apt-get-install-libmysqlclient-dev
然后在尝试安装
mysql
之后,我得到了以下错误:E:无法打开锁文件/var/lib/dpkg/lock-open(13:权限被拒绝)E:无法锁定管理目录(/var/lib/dpkg/),您是root用户吗?使用
sudo
sudo
表示
超级用户do
gem install mysql2