我有一个运行在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
我不知道错误是因为服务器还是因为数据库。
答案 0 :(得分:0)
OP解决方案。
我可以通过将MariaDB版本降级到10.1来安装mysql2 gem。目前,宝石本身存在一个问题(版本0.4)来源:Issue #877,Issue #932 我要么等待下一个版本的gem,要么将数据库降级到较低版本。
mysql2版本0.4.10应该与MariaDB 10.2一起使用