[英]Rails / MySQL2: Error - Unknown database
I'm following a basic tutorial in Linda. 我正在学习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
: 我现在已经能够正确安装所有内容,但是当我启动Rails服务器时,当我访问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/_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? 您是否在MySQL中创建了数据库? You should be able to run rake db:create
and have Rails create it for you. 您应该能够运行rake db:create
并让Rails为您创建它。
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: 寻找以下问题的答案:
rake db:create
? 您是否运行了rake db:create
命令? Sometimes creating database with rake causes issues. 有时使用rake创建数据库会导致问题。
You can also create the database inside mysql 您也可以在mysql内部创建数据库
Make sure mysql is in the root %PATH% in command prompt type echo %PATH% to check. 确保mysql在命令提示符下的根%PATH%中,键入echo%PATH%进行检查。
If it isn't in your PATH. 如果它不在您的PATH中。 Then do a quick google search on windows PATH to get instructions 然后在Windows PATH上进行快速Google搜索以获取说明
Open command prompt 打开命令提示符
type mysql -u root -p 输入mysql -u root -p
type your password that you created for your root 输入您为root用户创建的密码
To create database 创建数据库
create database simple_cms_development 创建数据库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:in
initialize /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:in
初始化
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 我如何临时解决此问题,只需将其注释掉
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.