I try to run gem 'thinking-sphinx' on my Ruby on Rails project, but something was wrong. When I run any search command on any model, I see this error: ThinkingSphinx::SphinxError (Unknown MySQL error).
More details:
MacOS Mojave -v 10.14.3
mysql -v 8.0.15 (Installed first)
Sphinx -v 2.2.11_2 (Installed via 'brew install sphinx')
thinking-sphinx -v 4.2.0
Rails -v 5.2.2
Before run search command, I runned rails ts:index and rails ts:start
What am I doing wrong?
Sphinx v2.2 (and 3.0) is not compatible with MySQL v8. You'll either want to downgrade MySQL to 5.7 - which can be done with homebrew via brew install mysql#5.7 - and then uninstall and reinstall Sphinx, or download the binaries for Sphinx v3.1.1 (the first version to support MySQL v8) from the Sphinx website (the source code for that release is not currently available, hence it's not installable via homebrew).
Just changed mysql2 from gem "mysql2", '~> 0.4.6' to gem "mysql2", '0.4.10' version, and it worked for me. Thanks
Related
Getting below error message logged in the console while starting the server for an application created with mysql database.
Failed to load libmysql.dll from C:\RailsInstaller\Ruby2.3.0\lib\ruby\gems\2.3.0\gems\mysql2-0.4.7-x86-mingw32\vendor\libmysql.dll
Environment Details :
Window 7 64 bit
Rails 5.0.4
ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]
mysqld Ver 5.7.18 for Win64 on x86_64 (MySQL Community Server (GPL))
Post install message from mysql2 ruby gem received below message on the console.
You've installed the binary version of mysql2.
It was built using MySQL Connector/C version 6.1.10.
It's recommended to use the exact same version to avoid potential issues.
At the time of building this gem, the necessary DLL files were retrieved from:
http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-6.1.10-win32.zip
This gem *includes* vendor/libmysql.dll with redistribution notice in vendor/README.
I have tried the solution from here but did not work.
Any help appreciated, thanks in advance.
Downgrading mysql2 rubygem from version 0.4.7 to 0.3.21 solved my issue.
Below steps I followed
rails new blog -d mysql # created application with mysql as database
gem uninstall mysql2 #uninstalled mysql2-0.4.7
Gemfile :
gem 'mysql2', '0.3.21' #Gemfile changed mysql2 version to 0.3.21
bundle update mysql2 #installed mysql2-0.3.21 version
Just as an update to this thread, specifying the platform of the gem did the job for me;
gem uninstall mysql2
gem install mysql2 --platform=ruby
And here is my version details:
Windows OS
Ruby 2.5.0p0 (2017-12-25 revision 61468) [i386-mingw32]
Rails 5.1.6
Gemfile:
gem 'mysql2', '0.5.1'
I'm getting the following error when running rake assets:precompile
Incorrect MySQL client library version! This gem was compiled for 5.6.10 but the client library is 5.5.12.
MySQL is installed using Homebrew and is version 5.6.10. I can connect to the database on 127.0.0.1 locally.
I've tried the following with no luck:
ARCHFLAGS="-arch x86_64" gem install mysql2 -- –with-mysql-config=/usr/local/bin/mysql_config
It seems that advice is for folks whose "client library" is newer than the one the Gem was compiled for. My issue is the opposite. Can't figure out where the 5.5.12 is coming from. Any ideas?
Try:
gem uninstall mysql
gem uninstall mysql2
Then
bundle install
I'm trying to install rails and its giving me a headache, I can't seem to get it working. I'm using osx 10.5 and I used macports to get rub,rails and ruby gems installed in opt/local/bin but mysql is getting frustrating, I have it working in a mamp directory, I also tried installing it via the dmg, which works but the profile won't work everytime I try to load it it says "Could not load mysql preference pane" and if I try in terminal type which mysql I get: /usr/local/mysql/bin/mysql but if I try to check the version I get :
mysql -version
dyld: unknown required load command 0x80000022
Trace/BPT trap
I'm trying to launch webrick inside a rails app i've created but when I run "rails server" I get the error:
Could not find gem 'mysql2 (>= 0)' in any of the gem sources listed in your Gemfile.
I have no idea whats going on
Isn't there an easy way to install rails like MAMP?
UPDATE:
ok I got mysql installed, apprently there is a bug with the latest version causing a problem with the preference pane. mysql is installed in
/usr/local/mysql/bin/mysql
2 questions I have about this. Is this the right path should it not be in /usr/local/mysql ?
and the second is how would I link this to my ruby gem? is this right:
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
or
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql/bin/mysql
I suggest you use HomeBrew to install mysql or ruby instead of MacPorts.
Could not find gem 'mysql2 (>= 0)' in any of the gem sources listed in your Gemfile.
This error is caused because rails requires the mysql2 gem to connect to mysql. All you have to do in include
gem mysql2
to the gemfile in the root directory of the rails app and do a bundle install
If you just trying out rails then you might as well use the default sqlite3 database forget about mysql.
The installation path is correct.
Installing the mysql gem is slightly more complicated than necessary since the installation automatically tries generating both 32bit and 64bit versions.
Assuming you have installed the 64 bit binary package, try the following (from the bash command line):
ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
However, it is recommended that you do not mess with the OSX ruby installation and use rvm (The Ruby Version Manager) to create a customized ruby environment. You can find a good tutorial for Rails and RVM here.
I am trying to get the mysql gem to work ... and it just doesn't want to. Every time I do a rake db:migrate, I get
uninitialized constant MysqlCompat::MysqlRes
I've installed mysql from this disk image: mysql-5.5.9-osx10.6-x86_64.dmg
I've run the gem install with the infamous archflags setting:
sudo env ARCHFLAGS="-arch x86_64" gem install --no-rdoc --no-ri mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
And the ruby version I'm using is the default from Snow Leopard:
[~/sites/testdb]$ file `which mysql`
/usr/local/mysql/bin/mysql: Mach-O 64-bit executable x86_64
[~/sites/testdb]$ file `which ruby`
/usr/bin/ruby: Mach-O universal binary with 3 architectures
/usr/bin/ruby (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/ruby (for architecture i386): Mach-O executable i386
/usr/bin/ruby (for architecture ppc7400): Mach-O executable ppc
My database.yml is pretty simple:
development:
adapter: mysql
host: 127.0.0.1
database: testdb
username: root
password:
Any help would be appreciated.
You can easy fix your problem.
If you don't use rvm:
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundleruby
If you use rvm:
install_name_tool -change libmysqlclient.16.dylib usr/local/mysql/lib/libmysqlclient.16.dylib [YOUR_GEMSET_PATH]/gems/mysql-2.8.1/lib/mysql_api.bundle
I blogged about this last week: MySQL 5.5 on Mac OS X.
My alternate solution to using install_name_tool is to set DYLD_LIBRARY_PATH in your shell startup files. The advantage to this you do it once, whereas if you use install_name_tool, you will repeat that every time to re-install or upgrade the gem.
The mysql2 gem will have the same problem with a slightly different error message. The problem is how the libmysqlclient library is built. It doesn't include a full path, so anything linking with it can't find it at runtime.
I ran into the same error. On my machine, though, the mysql gen was built when I still had mysql 5.1 on my machine. Now, after upgrading to MySQL 5.5, the dyld-file referred by the original build /usr/local/mysql/lib/libmysqlclient.16.dylib didn't exist any more and was replaced by a file /usr/local/mysql/lib/libmysqlclient.18.dylib.
Completely rebuilding the mysql gem fixed things, i.e.
gem uninstall mysql
gem install mysql
You could try using the mysql2 gem which may not suffer from the same problems.
I've found it's often a lot better to use ruby and mysql from MacPorts or brew to keep everything on the same page and not mess with the system Ruby.
OS X comes with a version of MySQL that may not match up with what you have installed, or perhaps the gem installer is confused about which config program to use. Make sure mysql_config is returning the correct path.
What do I need to install mysql gem on Mac OS X ? I'm getting error "failed to build native extensions".
Install MySQL first, either by using binary or Homebrew.
Then:
gem install mysql2
Or:
gem install ruby-mysql
Just pick one and you are good to go.
Edit
In case you upgraded to MySQL version 5.6.12 on OS X, mysql2 will fail to compile. Solution is to downgrade MySQL as described here: https://stackoverflow.com/a/17252887/45254
Edit2
In case you don't want to have mysql installed (maybe you use docker to manage your services) but do want to use mysql2 gem, you can instead install mysql-connector-c (using homebrew).
Some time back I wrote some instructions on my blog on how to do it in 10.6, but I think it's the same in 10.5.
I comes down to this command:
ARCHFLAGS="-arch x86_64" gem install mysql -- \
--with-mysql-config=/path/to/mysql_config
but you need to find the real value for /path/to/mysql_config. My blog post has a few tips, but there's one very important thing: you must have installed MySQL with headers. The official .pkg installer from MySQL doesn't IIRC. The best thing to do is to install MySQL with Homebrew (in the post I use examples from a MacPorts install, but that's because Homebrew wasn't mature when I wrote it).
If you install MySQL with Homebrew mysql_config will be located at /usr/local/bin/mysql_config and if you install it with MacPorts it will be at /opt/local/lib/mysql5/bin/mysql_config.
I concur with the other answer that suggest that you install the mysql2 gem instead of mysql. I think the command above should work for mysql2 too.
if you already have MySQL server running elsewhere on the network and would like to still install the gem without having to install MySQL try the following
brew install mysql-connector-c
followed by
gem install mysql
I'm running Mac OS X Lion with Homebrew.
The correct command to install a ruby gem is…
gem install mysql -- \ --with-mysql-config=/usr/local/bin/mysql_config
I'm using Mac OS X Mountain Lion, and installed MySQL with DMG.
gem install do_mysql -- \ --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include
and
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
This works for me ;)
For me it did the most easy:
brew install mysql
gem install mysql
Brew is a package manager for Mac OS, a must have. Using it to install mysql first brings everything that the gem command is missing.
I'm using Mac OS X 10.10 (Yosemite), and to me worked with the command bellow:
gem install mysql2 -- \ --with-mysql-config=/usr/local/mysql/bin/mysql_config
I installed MySQL with Homebrew and I had to use this to finally be able to upgrade the gem:
gem install mysql2 -- --with-mysql-dir=/usr/local/opt/mysql/
I install MySQL with DWG mysql_config will be located at /usr/local/mysql/bin/mysql_config
gem install mysql -- \ --with mysql-config=/usr/local/mysql/bin/mysql_config
I came across this issue while setting up MySQL gem on MacOs Mojave .This worked for me
1 Ensure Xcode command line tools are installed.
xcode-select --install
For me the build was still failing with some header files missing which you have to install
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
This link pointed to right direction. Can't compile C program on a Mac after upgrade to Mojave