【问题标题】:Error with the connection and install mysql2连接错误并安装mysql2
【发布时间】:2018-02-11 10:33:37
【问题描述】:

我想从命令行安装并连接到 mysql2,我的操作系统是 Ubuntu,我添加了用户以获得完全权限,但我仍然收到以下消息: 错误:执行 gem 时 ... (Errno::EACCES) 权限被拒绝@rb_sysopen - /var/lib/gems/2.3.0/gems/mysql2-0.4.9/CHANGELOG.md

:~/Desktop/simple_cms$ gem install mysql2 -v '0.4.9'
Building native extensions.  This could take a while...
/usr/lib/ruby/2.3.0/rubygems/ext/builder.rb:76: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/mysql2-0.4.9/ext/mysql2
/usr/bin/ruby2.3 -r ./siteconf20170903-6674-101jhbn.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=/usr/bin/$(RUBY_BASE_NAME)2.3
    --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

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.9/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/mysql2-0.4.9 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.9/gem_make.out

【问题讨论】:

  • 也许(只是猜测)您为“localhost”创建了用户,但正在连接到 127.0.0.1...如果您想要一个好的答案,恐怕您应该提供有关您如何创建/授予您的 mysql 用户和您的代码摘录。
  • localhost 是 127.0.0.1,这与用户无关,因为这是一个 IP 地址。
  • 您的用户无权访问这些文件。
  • 确保以该用户身份连接后,您可以访问该文件夹及其包含的文件。
  • 我正在添加你来自命令行的响应

标签: ruby-on-rails database


【解决方案1】:

如果您使用的是 mac 并通过自制软件安装了 mysql,请尝试以下操作:

brew link mysql

之后尝试再次安装 gem:

gem install mysql2

【讨论】:

  • fwiw 我安装了多个版本的 mysql mysql@5.5mysql@5.7 和另一个。我不得不执行brew link mysql@5.5 --force。请务必检查您的mysql --version 并链接到正确的版本。
猜你喜欢
  • 2012-12-21
  • 2017-01-28
  • 2011-08-12
  • 2011-04-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-09
相关资源
最近更新 更多