1
votes

I've recently upgraded to Rails 3 and am getting the following issue when trying to run rake db:create to create a mysql database of which has been defined in database.yml

Some info about my setup:

running snow leopard rails gem v3.0.3 mysql gem v2.8.1 mysql 5.5.8

I'm presented with this issue:

$rake db:create

(in /Users/elliottheis/Sites/demoProject)

rake aborted!

uninitialized constant Mysql::Error

(See full trace by running task with --trace)

Does anyone have any ideas how to solve this, it's driving me nuts!

2
@Karpie d'oh, please see revised edit aboveElliot
What's the output for rake db:create --trace ?Dogbert
snippet of the output is: "uninitialized constant Mysql::Error /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:64:in create_database' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:33 /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in call' "Elliot
Did you ever get this to work? I'm having the same problem, and I can't understand what other steps I can take. I have done everything that you have, and I verified that I can connect to the MySQL database with the credentials I outline in my database.yml file.Rick

2 Answers

1
votes

Make sure Mysql is in your Gemfile and the database.yml is setup for Mysql. Uninitialized constant simply and will most likely always mean you have not told Rails where to find it. It you can type mysql -uroot into Terminal and see the Version then you know that MySql is fine. Try post a bit more information and we will see if we cant get to the bottom of this.

rake -r mysql db:create --trace

If this does not work then something has gone wrong in the installation. Try This.

Uninstall Mysql - Follow these instructions Reinstall Mysql - Follow these instructions

Let us know how you get on and tell us the solution when you get it. All the best

1
votes

I know this has already been answered, but in case this happens to someone else, my issue was identical to Elliot's.

However, my fix revolved around using mysql gem 2.8 and Snow Leopard, which which is explained in another Stackoverflow thread:

As it turns out, that class should not exist; the error message is caused by a problem with the latest Mysql driver. mysql-2.8.1 looked for my libraries in a directory named with an extra level of ‘mysql’ at the end. For instance, my libraries (under MacOS X 10.5.8), are in /usr/local/mysql/lib, but the mysql.bundle library looks for the MySQL libraries at /usr/local/mysql/lib/mysql … which is wrong.

So I needed to install the mysql gem version before 2.8. Follow the instructions on this Web site, and your issue should be resolved.