I'm trying to get a database populate so I can begin working on a project. This project is already built and I'm being brought in to help with front-end work. Problem is I can't get rake db:migrate
to do any inserts. Every time I run rake db:migrate
I get this:
== 20081220084043 CreateTimeDimension: migrating ==============================
-- create_table(:time_dimension)
-> 0.0870s
INSERT time_dimension(time_key, `year`, `month`, `day`, day_of_week, weekend, quarter) VALUES(20080101, 2008, 1, 1, 'Tuesday', false, 1)
rake aborted!
Could not load driver (uninitialized constant Mysql::Driver)
I'm building on a MBP with Snow Leopard. I've installed XCode from the disk that comes with the mac. I've updated ruby, installed rails and all the needed gems. I have the 64 bit version of MySQL installed.
I've tried the 32 bit version of MySQL and I've even tried installing from macports .
The mysql gem is installed using: sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/path/to/mysql/bin/mysql_config
the migrate creates the tables just fine but it dies every single time it tries an insert.
Any help would be great
这些在Mac OS X Snow Leopard上安装MySQL的说明非常适合我: http : //hivelogic.com/articles/compiling-mysql-on-snow-leopard
Given the error you were getting, it looks like you haven't required the mysql gem. Other potential gotchas:
Edit: If you're doing ruby dev on Mac, I highly recommend using both homebrew and rvm .
If running 'mysql -u root' on your console works fine, then possibly reinstall your mysql gem using the instructions from hivelogic.com (as per John Topley's link) by typing this instead:
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
If you installed MySQL 64-bit as a pkg, try reinstalling by manual compile.
Tip on a side: Database migration is bad for seeding. If you use rails >= 2.3.4 then you should use db/seeds.rb and $ rake db:seed
task for this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.