无法在 RHEL 7 上为 MariaDB 连接安装 gem mysql2
Unable to install gem mysql2 on RHEL 7 for MariaDB connection
我在 Ruby 上有一个客户网站 运行,在他们决定升级到 MariaDB 之前正在使用 MySQL。因此,我必须重新配置网站以使用新数据库
服务器:RHEL 7
数据库:MariaDB 10.2
安装 gem 时出现此错误。
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p551/bin/ruby -r ./siteconf20180305-7942-1ltzloc.rb extconf.rb
checking for rb_absint_size()... no
checking for rb_absint_singlebit_p()... no
checking for ruby/thread.h... no
checking for rb_thread_blocking_region()... yes
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
-----
Using mysql_config at /usr/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for SSL_MODE_DISABLED in mysql.h... no
checking for MYSQL_OPT_SSL_ENFORCE in mysql.h... yes
checking for MYSQL.net.vio in mysql.h... no
checking for MYSQL.net.pvio in mysql.h... yes
checking for MYSQL_ENABLE_CLEARTEXT_PLUGIN in mysql.h... yes
-----
Setting libpath to /usr/lib64/
-----
creating Makefile
make clean
make
compiling statement.c
statement.c: In function ârb_raise_mysql2_stmt_errorâ:
statement.c:50:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
VALUE rb_error_msg = rb_str_new2(mysql_stmt_error(stmt_wrapper->stmt));
^
statement.c:57:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
rb_encoding *default_internal_enc = rb_default_internal_encoding();
^
In file included from ./mysql2_ext.h:35:0,
from statement.c:1:
statement.c: In function âexecuteâ:
./client.h:56:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
mysql_client_wrapper *wrapper; \
^
statement.c:273:3: note: in expansion of macro âGET_CLIENTâ
GET_CLIENT(stmt_wrapper->client);
^
statement.c:405:13: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
VALUE rb_val_as_string = rb_funcall(argv[i], intern_to_s, 0);
^
In file included from ./mysql2_ext.h:35:0,
from statement.c:1:
statement.c: In function âfieldsâ:
./client.h:56:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
mysql_client_wrapper *wrapper; \
^
statement.c:481:3: note: in expansion of macro âGET_CLIENTâ
GET_CLIENT(stmt_wrapper->client);
^
compiling result.c
result.c: In function ârb_mysql_result_alloc_result_buffersâ:
result.c:326:40: warning: assignment from incompatible pointer type [enabled by default]
wrapper->result_buffers[i].is_null = &wrapper->is_null[i];
^
result.c:328:40: warning: assignment from incompatible pointer type [enabled by default]
wrapper->result_buffers[i].error = &wrapper->error[i];
^
compiling mysql2_ext.c
compiling client.c
In file included from ./mysql2_ext.h:35:0,
from client.c:1:
client.c: In function ârb_set_ssl_mode_optionâ:
./client.h:56:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
mysql_client_wrapper *wrapper; \
^
client.c:118:3: note: in expansion of macro âGET_CLIENTâ
GET_CLIENT(self);
^
client.c:119:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
int val = NUM2INT( setting );
^
client.c:145:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
compiling infile.c
linking shared-object mysql2/mysql2.so
/usr/bin/ld: cannot find -lmariadb
collect2: error: ld returned 1 exit status
make: *** [mysql2.so] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p551/gems/mysql2-0.4.10 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p551/extensions/x86_64-linux/1.9.1/mysql2-0.4.10/gem_make.out
不知道是服务器的问题还是数据库的问题。
OP 的解决方案。
我可以通过将 MariaDB 版本降级到 10.1 来安装 mysql2 gem。目前,gem 本身(版本 0.4)中存在与此相关的问题来源:Issue #877, Issue #932
要么我等待 gem 的下一个版本,要么我将数据库降级到较低版本。
mysql2 版本 0.4.10 应与 MariaDB 10.2
一起使用
我在 Ruby 上有一个客户网站 运行,在他们决定升级到 MariaDB 之前正在使用 MySQL。因此,我必须重新配置网站以使用新数据库
服务器:RHEL 7
数据库:MariaDB 10.2
安装 gem 时出现此错误。
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p551/bin/ruby -r ./siteconf20180305-7942-1ltzloc.rb extconf.rb
checking for rb_absint_size()... no
checking for rb_absint_singlebit_p()... no
checking for ruby/thread.h... no
checking for rb_thread_blocking_region()... yes
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
-----
Using mysql_config at /usr/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for SSL_MODE_DISABLED in mysql.h... no
checking for MYSQL_OPT_SSL_ENFORCE in mysql.h... yes
checking for MYSQL.net.vio in mysql.h... no
checking for MYSQL.net.pvio in mysql.h... yes
checking for MYSQL_ENABLE_CLEARTEXT_PLUGIN in mysql.h... yes
-----
Setting libpath to /usr/lib64/
-----
creating Makefile
make clean
make
compiling statement.c
statement.c: In function ârb_raise_mysql2_stmt_errorâ:
statement.c:50:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
VALUE rb_error_msg = rb_str_new2(mysql_stmt_error(stmt_wrapper->stmt));
^
statement.c:57:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
rb_encoding *default_internal_enc = rb_default_internal_encoding();
^
In file included from ./mysql2_ext.h:35:0,
from statement.c:1:
statement.c: In function âexecuteâ:
./client.h:56:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
mysql_client_wrapper *wrapper; \
^
statement.c:273:3: note: in expansion of macro âGET_CLIENTâ
GET_CLIENT(stmt_wrapper->client);
^
statement.c:405:13: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
VALUE rb_val_as_string = rb_funcall(argv[i], intern_to_s, 0);
^
In file included from ./mysql2_ext.h:35:0,
from statement.c:1:
statement.c: In function âfieldsâ:
./client.h:56:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
mysql_client_wrapper *wrapper; \
^
statement.c:481:3: note: in expansion of macro âGET_CLIENTâ
GET_CLIENT(stmt_wrapper->client);
^
compiling result.c
result.c: In function ârb_mysql_result_alloc_result_buffersâ:
result.c:326:40: warning: assignment from incompatible pointer type [enabled by default]
wrapper->result_buffers[i].is_null = &wrapper->is_null[i];
^
result.c:328:40: warning: assignment from incompatible pointer type [enabled by default]
wrapper->result_buffers[i].error = &wrapper->error[i];
^
compiling mysql2_ext.c
compiling client.c
In file included from ./mysql2_ext.h:35:0,
from client.c:1:
client.c: In function ârb_set_ssl_mode_optionâ:
./client.h:56:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
mysql_client_wrapper *wrapper; \
^
client.c:118:3: note: in expansion of macro âGET_CLIENTâ
GET_CLIENT(self);
^
client.c:119:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
int val = NUM2INT( setting );
^
client.c:145:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
compiling infile.c
linking shared-object mysql2/mysql2.so
/usr/bin/ld: cannot find -lmariadb
collect2: error: ld returned 1 exit status
make: *** [mysql2.so] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p551/gems/mysql2-0.4.10 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p551/extensions/x86_64-linux/1.9.1/mysql2-0.4.10/gem_make.out
不知道是服务器的问题还是数据库的问题。
OP 的解决方案。
我可以通过将 MariaDB 版本降级到 10.1 来安装 mysql2 gem。目前,gem 本身(版本 0.4)中存在与此相关的问题来源:Issue #877, Issue #932 要么我等待 gem 的下一个版本,要么我将数据库降级到较低版本。
mysql2 版本 0.4.10 应与 MariaDB 10.2
一起使用