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

General Discussion

HI everyone I have a database question as far as applying them goes?

Hey everyone I'm about to finish the database stage on here. I know that they can be incorporated into websites. I also know that I may be asking this question prematurely as I have much more to learn with ruby. What I need to know is how to apply databases to a website. Once I've built them, how do I make them searchable for people veiwing the site also, can they be setup in a way that once they've been constructed others can add to them using a form and have the information sent to and applied to the database. I will be building a website soon that deals with reviews and obviously databases have to be a part of that.

Where is a great place to get more information and practice. Thanks in advance for all advise given.

9 Answers

Alan Johnson
Alan Johnson
7,625 Points

Great question! I'd definitely recommend digging into either our Rails or PHP tracks. They cover the technology you'll need to know to do what you're asking.

Great thanks I will definitely do that.

Hi Alan Johnson I know that it has been a while that I have said anything in this post. I have followed your advise and I am still definitely excited to continue my learning with ROR, but I have been stuck since this post. I have not been able to get past the migration video. http://teamtreehouse.com/library/rails-models/migrations-and-relationships/migrations

It is not that I do not understand what is being presented I've just been facing major issues with this and I amd in desperate need of help. I have posted questions in the forum and people have tried to help me. I have also spent days trolling google but all thus far to no avail. I have uninstalled Ruby, Mysql and Mysql Workbench. I have also rebuilt biller (from the video many times).

Here are my challenges:

  1. When I build biller the first challenge that I face is with the "rake db:create" command ( I did not have this problem working through previous videos). The command continously failsas it says that the disk image cannot be found. I finally got around that by running : "export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"

First then when I run the 'rake db:create command' I do not have a problem.

  1. The next challenge that I faced was running'mysql -uroot'. I finally got past this by running: /usr/local/mysql/bin/mysql
    First, then the mysql -u root command works just fine.

  2. When I get to the part where it is time to 'show databases' , biller never shows. Information_schema and test shows. biller_development and biller_test show in mysql workbench but not in the 'show databases' list. When I try to 'Create DATABASE' it firstly tells me that I do not have permission to do so, then it tells me that database that I am trying to create already exists. So I went to mysql workbench and deleted it from there. Started over again but, I still cannot get past this poing. When I am told that biller_developmen and biller_test already exists even though it does not show in the listing I tried using it just to see what would happen then I am told that the database does not exist.

I know that this post is a little long but I also know that details are neccessary. I have searched google and the forum countless times, and asked many questions. Yet I am still stuck. I know that I have much to learn, I also know that there will be many times when I will need to recive and give help. Please if you have the time help me as I am truly stuck here. And as I defintely need to be successful with ROR to obtain my goals. Thank you in advance.

Alan Johnson
Alan Johnson
7,625 Points

It looks like most of your issues are path related. How did you go about installing MySQL?

I downloaded the MySQL installer, I unzipped it and dragged the image to my preferences pane. I also downloaded and installed MySQL workbench. I followed the steps in the video. I've even uninstalled both of these and re-installed them without success. What do you suggest I try next, I really need to get this working. Thanks in advance.

Alan Johnson
Alan Johnson
7,625 Points

I'd recommend uninstalling MySQL and installing it using Homebrew. It's a little more complex to install, but works really well and handles the tricky edge cases for you. Installation instructions are on their homepage. Once you have Homebrew installed, you can run:

brew install mysql

to get MySQL installed. At the end of the installation they outline some extra steps to make sure MySQL starts when your computer does.

I hope that helps. Definitely follow up here if you have more questions.

Thank you Alan I will definitely try this in a few hours.

I did as you suggested Alan and I am still stuck! There is not change when I try to execute commands. The new "biller" database is not showing in my list but it does show in MySQL Workbench. Is this supposed to be this confusing.

Alan Johnson
Alan Johnson
7,625 Points

It's definitely not supposed to be this confusing. Can you share the command you're running and the output that you're seeing when you run it?

This is the first command that I run: rails new biller -d mysql

No problems there. Then I go into biller with: cd biller/

No problems there.Then I run 'ls", and this is my output: Gemfile Rakefile config lib test Gemfile.lock app config.ru log tmp README.rdoc bin db public vendor

I have compared this with the teachers own in the video and there is a difference. His Gemfile.lock has bin in front of it where as my own has what is shown above.

I open in in sublime text which has never been an issue.

Then I run "rake db:create", I get the following print out: LoadError: dlopen(/usr/local/rvm/gems/ruby-1.9.3-p392/gems/mysql2-0.3.16/lib/mysql2/mysql2.bundle, 9): Library not loaded: @@HOMEBREW_PREFIX@@/opt/openssl/lib/libssl.1.0.0.dylib Referenced from: /usr/local/lib/libmysqlclient.18.dylib Reason: image not found - /usr/local/rvm/gems/ruby-1.9.3-p392/gems/mysql2-0.3.16/lib/mysql2/mysql2.bundle /usr/local/rvm/gems/ruby-1.9.3-p392/gems/mysql2-0.3.16/lib/mysql2.rb:8:in require' /usr/local/rvm/gems/ruby-1.9.3-p392/gems/mysql2-0.3.16/lib/mysql2.rb:8:in<top (required)>' /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.7.2/lib/bundler/runtime.rb:76:in require' /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.7.2/lib/bundler/runtime.rb:76:inblock (2 levels) in require' /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.7.2/lib/bundler/runtime.rb:72:in each' /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.7.2/lib/bundler/runtime.rb:72:inblock in require' /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.7.2/lib/bundler/runtime.rb:61:in each' /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.7.2/lib/bundler/runtime.rb:61:inrequire' /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.7.2/lib/bundler.rb:133:in require' /Users/aspire/biller/config/application.rb:7:in<top (required)>' /Users/aspire/biller/Rakefile:4:in `<top (required)>' (See full trace by running task with --trace)

I found that if I use this command: export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"

Then rake db:create runs without a problem(except sometimes it will tell me that biller_development and biller_test already exist.)

"biller_development already exists biller_test already exists"

When I try to run 'mysql -uroot' I now get: dyld: Library not loaded: @@HOMEBREW_PREFIX@@/opt/openssl/lib/libssl.1.0.0.dylib Referenced from: /usr/local/bin/mysql Reason: image not found Trace/BPT trap: 5

I use to get command not found but I did follow your last suggestion with HomeBrew. Before I used Homebrew I would run:

/usr/local/mysql/bin/mysql

This would allow me to then run mysql -u root.

Now I am getting this when I try to use /usr/local/mysql/bin/mysql.

ERROR 1045 (28000): Access denied for user 'aspire'@'localhost' (using password: NO)

So this is where I am stuck at , at this point.

Okay I know that I mentioned some major issues that I was having. I am happy to report that those issues have since been fixed. As I mentioned above I did try the HomeBrew method but that initially did not take. Even after I deleted all ROR and MYSQL programs.

What I ended up doing was finding commands to run in the terminal that removed all components from my mac ( as many of the gems stayed behind even after deleting the programs). I also deleted GCC as Homebrew said that , that was a problem. Once I deleted GCC I searched my mac and once again there were residual files. I deleted all of them. I did 'Secure Empty Trash'. Then I updated my system.

After I updated my system and re-installing the software(which was interesting as some of the software did not want to work with 10.9 OS X). I was still having issues. I would have given up if this was not so important to me. I ran "brew update" and "brew doctor" several times. I was still stuck. I kept trolling the internet and finally found commands that worked.

For HomeBrew I ran " brew link openssl --forced"(apparently there is a bug in HomeBrew that has nnot been fixed as yet but this iworked for me). Then to access MySQL I ran the command " mysql -u root -p" put in my password and presto. Everything showed and I was able to access it and get through the video and build the schema. Getting this software was a rough journey but if anybody else has a problem (although problems like mine don't seem to happen often) do not give up.

Thanks Alan this is my update :D .

Alan Johnson
Alan Johnson
7,625 Points

Hi Peaches! That's awesome.

Figuring out problems like this can be a total pain, but it's definitely part of the life of a programmer. I'm glad you came out victorious!

Thanks Alan and as frustrating as it was ,(many headaches) . I'm glad I feel like I can handle anything that Ruby throws at me now. :D