Comments (6)
If anyone is still having this problem - I needed both a recent MariaDB and a 5.x MySQL server running in parallel on my Mac and ran into the same problem described above when I tried to use DBIng for the multi-server setup.
I solved it by installing mysql 5.7 via brew AS WELL as via DBIng. The DBIng option is great for running the server as it works out of the box without any hassles - it also recognised my existing MariaDB install straight away.
To configure the mysql2 gem for the 5.7 server I did:
brew install [email protected]
gem install mysql2 -v '0.3.18' -- --with-mysql-config=$MYSQL5/bin/mysql_config
(the MYSQL5 environment variable is set by the brew install, in my case it was /usr/local/Cellar/[email protected]/5.7.29)
My last problem was then that the mysql2 gem was linked to the wrong mysql client library - when running the rails server I got
Gem Load Error is: Incorrect MySQL client library version! This gem was compiled for 5.7.29 but the client library is 10.4.12.
To fix that, locate the mysql2.bundle
file that was created when the mysql2 gem was installed - I am using RVM, so in my case it was here:
cd /Users/patsch/.rvm/gems/ruby-2.3.8@awsa/gems/mysql2-0.3.18/lib/mysql2
I then checked the libraries it was linked against:
otool -L mysql2.bundle
This then showed that the mysql2.bundle
had been told to use the mariadb runtime, instead of the mysql5 runtime:
mysql2.bundle:
/usr/local/opt/mariadb/lib/libmariadb.3.dylib (compatibility version 3.0.0, current version 3.0.0)
To change that, I then ran
install_name_tool -change /usr/local/opt/mariadb/lib/libmariadb.3.dylib /usr/local/Cellar/[email protected]/5.7.29/lib/libmysqlclient.20.dylib mysql2.bundle
and now Rails is happy :-)
from dbngin.
This is how I worked around this issue. It might not be the best solution but it suits my needs. The following code is from freshly created rails app.
-
Added mysql database to the path in .zshrc since it couldn't find the database even after I clicked on exporting the environment variables to terminal.
export PATH="$HOME/.yarn/bin:$HOME/.rvm/bin:/Users/Shared/DBngin/mysql/8.0.19/bin:$PATH"
-
I am using rvm and I created a gemset for my project.
rvm use ruby-2.7.0@railsapp --ruby-version --create
-
Then created a local bundle file to set mysql2 with the new mysql_config installed by dbngin
cd railsapp
then
bundle config --local build.mysql2 --with-mysql-config=/Users/Shared/DBngin/mysql/8.0.19/bin/mysql_config
this will createapp/.bundle/config
file and it is ignored in .gitignore file. -
I added the socket option to database.yml file to specify dbngin's socket
default: &default
adapter: mysql2
socket: "/tmp/mysql_3306.sock"
encoding: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password: 'root' // I changed the password of root through ALTER USER using tableplus
host: localhost
- I ran
bundle install
. After bundler finished installing the gems, I ranbin/rails db:create
and I got my database created successfully.
from dbngin.
Hi @joneslee85 can you run this command in terminal, and the try rake migrate again?
cd /Users/Shared/DBngin/mysql/5.7.23/lib
install_name_tool -id /Users/Shared/DBngin/mysql/5.7.23/lib/libmysqlclient.20.dylib libmysqlclient.20.dylib
from dbngin.
same problem here.
cd /Users/Shared/DBngin/mysql/5.7.23/lib
install_name_tool -id /Users/Shared/DBngin/mysql/5.7.23/lib/libmysqlclient.20.dylib libmysqlclient.20.dylib
run this command does not help.
from dbngin.
@huyphams it does not really help unfortunately
from dbngin.
It's been awhile. I've working around the issue by installing the MySQL DB separately so that its headers can be looked up and used by clients such as mysql2 rubygems.
from dbngin.
Related Issues (20)
- Can't Remove Services HOT 4
- MySQL 8.1 HOT 3
- Error while setting value 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' to 'sql_mode' HOT 1
- How to completely remove all traces of an old database? HOT 1
- Feature: Restart Homebrew services
- DB Active state in Desktop Window not synchronized with Menu Window
- Can't open MySQL 8 server with SequelPro HOT 1
- Command to stop all services
- Homebrew Services not detected HOT 1
- Super strange Wordpress / Laravel Bug HOT 3
- PostgreSQL config file not found
- Can't access Mysql from terminal HOT 1
- UI glitch, then won't open app until force exit HOT 1
- DBnign crashes when opening the app HOT 11
- Bug "Open TablePlus"
- Feature Request: Hide DBngin Dock Icon HOT 1
- Can I only a button to hide icon from dock and just show in menu bar?
- Add a warning when selecting where to store DB files, that it will wipe any content in that folder HOT 2
- Add support for dragonflydb
- TablePlus doesn't show up and Mysql client can not connect to DBngin HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dbngin.