我一直试图在我的Ubuntu 20.04上安装mysql2 gem版本0.3.21
,但得到以下错误。
构建本地扩展。这可能要花点时间。。错误:安装mysql2时出错:错误:无法生成gem本机扩展。
current directory: /home/user/.rvm/gems/ruby-2.5.3/gems/mysql2-0.3.21/ext/mysql2
/home/user/.rvm/rubies/ruby-2.5.3/bin/ruby -I /home/user/.rvm/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0 -r ./siteconf20210822-101581-13t36qj.rb extconf.rb
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
-----
Using mysql_config at /usr/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Setting libpath to /usr/lib/x86_64-linux-gnu
-----
creating Makefile
current directory: /home/user/.rvm/gems/ruby-2.5.3/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR=" clean
current directory: /home/user/.rvm/gems/ruby-2.5.3/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR="
compiling client.c
client.c: In function ‘nogvl_read_query_result’:
client.c:439:3: error: unknown type name ‘my_bool’; did you mean ‘bool’?
439 | my_bool res = mysql_read_query_result(client);
| ^~~~~~~
| bool
client.c: In function ‘_mysql_client_options’:
client.c:762:3: error: unknown type name ‘my_bool’; did you mean ‘bool’?
762 | my_bool boolval;
| ^~~~~~~
| bool
client.c:797:10: error: ‘MYSQL_SECURE_AUTH’ undeclared (first use in this function); did you mean ‘MYSQL_DEFAULT_AUTH’?
797 | case MYSQL_SECURE_AUTH:
| ^~~~~~~~~~~~~~~~~
| MYSQL_DEFAULT_AUTH
client.c:797:10: note: each undeclared identifier is reported only once for each function it appears in
client.c: In function ‘set_secure_auth’:
client.c:1185:38: error: ‘MYSQL_SECURE_AUTH’ undeclared (first use in this function); did you mean ‘MYSQL_DEFAULT_AUTH’?
1185 | return _mysql_client_options(self, MYSQL_SECURE_AUTH, value);
| ^~~~~~~~~~~~~~~~~
| MYSQL_DEFAULT_AUTH
client.c:1186:1: warning: control reaches end of non-void function [-Wreturn-type]
1186 | }
| ^
client.c: At top level:
cc1: warning: unrecognized command line option ‘-Wno-self-assign’
cc1: warning: unrecognized command line option ‘-Wno-constant-logical-operand’
cc1: warning: unrecognized command line option ‘-Wno-parentheses-equality’
make: *** [Makefile:242: client.o] Error 1
make failed, exit code 2
到目前为止,我已经遵循了其他解决方案,在其他类似的问题上Stackoverflow像安装default-libmysqlclient-dev
libmysqlclient-dev
,但没有运气到目前为止。
我的MySQL服务器版本是5.7.35
4条答案
按热度按时间4ioopgfo1#
不妨试试这个:
和
vh0rcniy2#
我解决了这个问题。我运行了以下命令
其中srcdir指向mysql的本地安装。
q7solyqu3#
谢谢,上面的答案帮到我了。只是一开始我必须找出我的mysql
yqyhoc1h4#
问题的原因是您安装了不兼容版本的libmysqlclient-dev包,在Ubuntu 20.04中默认对应MySQL 8.0
只是你需要删除已安装的版本,并安装相应的如下below。
假设我尝试了MySQL 5.7.39的版本,但你可以在其他仓库中找到5.7.35;下一篇:http://repo.mysql.com/apt/ubuntu/pool/mysql-5.7/m/mysql-community
删除当前安装的:
使用dpkg -i下载并安装依赖包
**更新:**我需要在另一台旧机器上解决这个问题Ubuntu 20.04与MySQL 5.7服务器。未找到以前的包链接,并使用了这些:
然后在Ubuntu 20.04上安装mysql 2 gem版本'0.3.21'就可以了!!