Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Trey Lewis
5,485 Pointsrake db:create - rake aborted!
On my Mac I'm running OS X 10.9.5 and just installed MySQL Community Server 5.6.21. When I enter the "rake db:create" command from this lesson I get "rake aborted!" with the following details:
rake aborted!
LoadError: dlopen(/Users/tlewis/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/mysql2-0.3.16/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Users/tlewis/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/mysql2-0.3.16/mysql2/mysql2.bundle
Reason: image not found - /Users/tlewis/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/mysql2-0.3.16/mysql2/mysql2.bundle
/Users/tlewis/treehouse/projects/biller/config/application.rb:7:in `<top (required)>'
/Users/tlewis/treehouse/projects/biller/Rakefile:4:in `<top (required)>'
How should I fix this error?
2 Answers
Aimee Ault
29,193 PointsSounds like you need to add the library path to your bash profile or failing that, you should be able to symlink like so from your command line:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
Nick Stoneman
10,093 PointsTrey-
I had the same problem as you. Followed Aimee's advice and added the library path. I also got same error: "-bash: mysql: command not found"
I was pretty sure it was still a path issue, as I installed mySql and workbench in a higher/different path during the DB foundations course, vs the same path as my ruby projects folder.
So I googled the command + the error message and found this stack exchange thread:
And then ran:
PATH=$PATH:/usr/local/mysql/bin
I then re-ran:
mysql -uroot
Trey Lewis
5,485 PointsThank you Nick. That fixed the "mysql: command not found" error.
Aimee Ault
29,193 PointsAh yep, that too! Teamwork! high five
You might need to actually add that to your bash profile in ~/.bash_profile for it to stick every time you open a new terminal session.
There's generally a bunch of lines like that already, so you'd just need to add
export PATH=$PATH:/usr/local/mysql/bin
to the bottom.
Trey Lewis
5,485 PointsTrey Lewis
5,485 PointsThank you Aimee. That worked!
However when I entered the next command from my application's directory of "mysql -uroot", I got this next error: "-bash: mysql: command not found"
Is there something else I need to add?
Christ khodabakhshi
10,916 PointsChrist khodabakhshi
10,916 PointsAimee Ault can you explain a little bit that what is the line gonna do ? I used the command and it fixed my problem but I couldn't figure out it.
Aimee Ault
29,193 PointsAimee Ault
29,193 PointsThe ln command is used for creating symlinks (links between files). So if something is looking for MySQL in /usr/lib/libmysqlclient.18.dylib, which may not exist if you're getting errors, your operating system will make up a file that points it in the right direction where you have the client installed, in /usr/local/mysql/lib instead :) It basically just fixes any difference between where you installed MySQL and where it's expecting to find it.
Christ khodabakhshi
10,916 PointsChrist khodabakhshi
10,916 PointsThank you very much :D
Christ khodabakhshi
10,916 PointsChrist khodabakhshi
10,916 Pointswhere can I add this command to make this change permanent?