mysql2 icon indicating copy to clipboard operation
mysql2 copied to clipboard

mysql2 0.4.10 Symbol not found: _mysql_server_init

Open mike-bhs opened this issue 5 years ago • 4 comments

My current project uses ruby 2.3.1, rails 4.2.7.1 and mysql2 0.4.10, I'm running all that on MacOS Catalina 10.15.3

Installed mysql2 with no errors:

$ gem install mysql2 -v '0.4.10' -- --with-mysql-dir=/usr/local/opt/[email protected]
Fetching mysql2-0.4.10.gem
Building native extensions with: '--with-mysql-dir=/usr/local/opt/[email protected]'
This could take a while...
Successfully installed mysql2-0.4.10
Parsing documentation for mysql2-0.4.10
Installing ri documentation for mysql2-0.4.10
Done installing documentation for mysql2 after 0 seconds
1 gem installed

got an error after trying to create db:

$ bundle exec rake db:create
dyld: lazy symbol binding failed: Symbol not found: _mysql_server_init
  Referenced from: /Users/mike/.rvm/gems/ruby-2.3.1@projectname/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle
  Expected in: flat namespace

dyld: Symbol not found: _mysql_server_init
  Referenced from: /Users/mike/.rvm/gems/ruby-2.3.1@projectname/gems/mysql2-0.4.10/lib/mysql2/mysql2.bundle
  Expected in: flat namespace

[1]    58001 abort      bundle exec rake db:create

The solution described at issue #1001 didn't help.

Please advice how to resolve it.

mike-bhs avatar Jan 31 '20 08:01 mike-bhs

This error indicates that the mysql libraries can not be found during runtime. This is most probably because the directory containing the mysql libraries is not in one of the “standard” paths. (Note that specifying --with-mysql-dir at compile time does not impact the runtime search paths.)

One way to solve this problem is with brew link --force [email protected] (because this will make the runtime library available in a standard path).

noniq avatar Feb 12 '20 22:02 noniq

if you face the issue on mac big sur with mysql 8.0.26. You need to provide mysql dir as explained in docs

$ gem install mysql2 -v '0.5.3' -- --with-mysql-dir=/opt/homebrew/Cellar/mysql-client/8.0.26

Clivern avatar Nov 03 '21 10:11 Clivern

Having the same issue as above except I am running Monterrey on an M1 mac and none of those potential solutions seem to work.

ritec avatar Oct 19 '22 16:10 ritec

Any one have solution for this issue of 'mysql2', '~> 0.3.0'? I am using Monterrey on an M1 mac.

Aishwarya-Yanduri avatar Nov 20 '22 11:11 Aishwarya-Yanduri