rails + MySQL on OSX: Library not loaded: libmysqlclient.18.dylib
The solution is pretty easy; Add the library path in your ~/.bash_profile or ~/.profile file:
MYSQL=/usr/local/mysql/bin
export PATH=$PATH:$MYSQL
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
If it is still not working (this work for me):
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
There are many blogs with install_name_tool
, which won't work for me because I'm on OSX Lion:
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/bin/indexer
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/bin/search
Rails on OSX 10.11 El Capitan: Library not loaded: libmysqlclient.18.dylib
The previous answer (pre El Capitan), was to create a symbolic link from mysql's lib directory for the library file into /usr/lib, like this:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
However this now produces 'operation not permitted' due to OS X's integrity controls. This can be worked around by disabling this. However a much easier solution (and one I can verify has worked) is to just symlink it into /usr/local/lib instead:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
Good ol' Apple.
El Capitan upgrade: Library not loaded: /usr/local/lib/libmysqlclient.18.dylib
I was getting the same issue earlier on, I fixed it by reinstalling the gem mysql2
.
Why do I get a Library not loaded: libmysqlclient.18.dylib error?
The syntax should be: rake db:migrate
, and not rake: dbmigrate
or rake db migrate
.
rails-mysql rake db :create - Library not loaded libmysqlclient.20.dylib image not found
The fix was to
gem uninstall mysql2
then reinstall it again with
bundle # gem install mysql2 would also work
This recompiles and resolves the reference that had been left over from having mysql 5.7.9 installed.
Related Topics
Error: Tcp Provider: Error Code 0X2746. During the SQL Setup in Linux Through Terminal
Adding an Identity to an Existing Column
Difference Between Join and Inner Join
How to See the Raw SQL Queries Django Is Running
How to Tell When a MySQL Table Was Last Updated
How to Insert a Line Break in a SQL Server Varchar/Nvarchar String
Select Max Value of Each Group
Bash Script to Insert Values in MySQL
SQL Split Values to Multiple Rows
What Is the Meaning of the Prefix N in T-SQL Statements and When Should I Use It
Why Does Null = Null Evaluate to False in SQL Server