开发者

Rails / MySQL2: Error - Unknown database

I'm following a basic tutorial in Linda. I have been able to install everything properly now, but when I start my Rails server I get this message when I visit localhost:3000:

Unknown database 'simple_cms_development'

and then

Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues/开发者_JS百科_trace.erb (1.0ms)
Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (23.5ms)
Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (29.8ms)


Have you created the database in MySQL? You should be able to run rake db:create and have Rails create it for you.


I had the same error, please run the following command on the Command Prompt:

rake db:create 

to solve the problem.


Look for the answers of these questions:

  1. Have you installed the mysql2 gem?
  2. Is it mentioned in your Gemfile?
  3. Did you run the command rake db:create ?


Sometimes creating database with rake causes issues.

You can also create the database inside mysql

Make sure mysql is in the root %PATH% in command prompt type echo %PATH% to check.

If it isn't in your PATH. Then do a quick google search on windows PATH to get instructions

Open command prompt

type mysql -u root -p

type your password that you created for your root

To create database

create database simple_cms_development

done


was getting the same error but caused was different

Mysql2::Error: Unknown database 'rdddd_development'

/Users/.rvm/gems/ruby-2.6.3/gems/mysql2-0.5.2/lib/mysql2/client.rb:90:in connect' /Users/commeasure/.rvm/gems/ruby-2.6.3/gems/mysql2-0.5.2/lib/mysql2/client.rb:90:ininitialize

faced this error due to the created method dynamically, code is here

Role.all.map(&:name).map(&:parameterize).map(&:underscore).each do |name|
    define_method("#{name.to_sym}?") do
     role.name == name.upcase
    end
  end

How do I fix this for the temporary purpose just comment it out

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜