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
Anna Petry
14,474 PointsActiveRecord db:create error
Hi!
I've begun the Active Record Deep Dive and have run into an error that I want to clear up before moving forward.
When I tried to run rake db:create I was met with this error:
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "pool"=>5, "username"=>"root", "password"=>nil, "host"=>"localhost", "database"=>"timely_development"}, {:charset=>"utf8", :collation=>"utf8_unicode_ci"}
(If you set the charset manually, make sure you have a matching collation)
I actually get that error twice with just the one command.
I've looked at StackOverflow, but either the proposed fixes don't work for me, or I don't understand them. (I'm too much of a SO n00b to be able to make comments, so I can't clarify people's answers.)
Any help would be SUPREMELY appreciated.
For what it's worth, I can successfully start the mysql server, and my database.yml file looks like this:
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password:
host: localhost
development:
<<: *default
database: timely_development
### Comments omitted for brevity's sake
<<: *default
database: timely_test
### More comments omitted
production:
<<: *default
database: timely_production
username: timely
password: <%= ENV['TIMELY_DATABASE_PASSWORD'] %>
Thanks for your time!
EDIT: Jeez, I don't know how it happened, but I ran the 'rake db:create' command for the millionth time, and it worked! I can't provide any insight into how it worked, and for that I am sorry! Good luck!
2 Answers
Kang-Kyu Lee
53,143 PointsHi Anna, was it... MySQL starting issue? Just in case,
mysql.server start
brew services start mysql
might have been needed.
ivan quevedo
4,477 PointsI have the same error.
Anna Petry
14,474 PointsAnna Petry
14,474 PointsHey Kang,
Thanks for the comment. I was able to successfully start mysql server and was still getting the error.
I wish I knew why it worked all of a sudden!