无法在 Ubuntu 19.04 上将 mySQL 连接到 Ruby on Rails

无法在 Ubuntu 19.04 上将 mySQL 连接到 Ruby on Rails

我在 Ubuntu 19.04 上安装 Ruby Gems 时遇到了困难。每当我尝试安装 gem 时,都会出现 make failed, exit code 2。但是,MySQL 已正确安装在我的操作系统上。甚至 Ruby 服务器也可以运行,但没有 MySQL 数据库。

greyshader@ScarlettHaven:~$ sudo gem install mysql
Building native extensions. This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.5.0/gems/mysql-2.9.1/ext/mysql_api
/usr/bin/ruby2.5 -r ./siteconf20190611-30763-iq3xfl.rb extconf.rb
checking for mysql_ssl_set()... yes
checking for rb_str_set_len()... yes
checking for rb_thread_start_timer()... no
checking for mysql.h... yes
creating Makefile

current directory: /var/lib/gems/2.5.0/gems/mysql-2.9.1/ext/mysql_api
make "DESTDIR=" clean

current directory: /var/lib/gems/2.5.0/gems/mysql-2.9.1/ext/mysql_api
make "DESTDIR="
compiling mysql.c
mysql.c: In function ‘stmt_bind_result’:
mysql.c:1320:74: error: ‘rb_cFixnum’ undeclared (first use in this function); did you mean ‘rb_isalnum’?
  else if (argv[i] == rb_cNumeric || argv[i] == rb_cInteger || argv[i] == rb_cFixnum)
                                                                          ^~~~~~~~~~
                                                                          rb_isalnum
mysql.c:1320:74: note: each undeclared identifier is reported only once for each function it appears in
make: *** [Makefile:243: mysql.o] Error 1

make failed, exit code 2

Gem files will remain installed in /var/lib/gems/2.5.0/gems/mysql-2.9.1 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/mysql-2.9.1/gem_make.out

我的 Ruby 版本是:

greyshader@ScarlettHaven:~$ ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]

我的 Rails 版本是:

greyshader@ScarlettHaven:~$ rails --version
Rails 6.0.0.rc1

但是当我尝试查看 mySQL 上的版本时,出现错误:

greyshader@ScarlettHaven:~$ mysql -version
ERROR 1045 (28000): Access denied for user 'greyshader'@'localhost' `(using password: NO)`

答案1

似乎不再支持此 gem。请尝试使用 mysql2-gem

相关内容