Rails / MySQL2:错误 - 未知数据库
我正在学习 Linda 的基本教程。 我现在已经能够正确安装所有内容,但是当我启动 Rails 服务器时,我在访问 localhost:3000 时收到此消息:
Unknown database 'simple_cms_development'
然后
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)
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/_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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
你在MySQL中创建了数据库吗?您应该能够运行 rake db:create 并让 Rails 为您创建它。
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:
to solve the problem.
寻找这些问题的答案:
rake db:create
?Look for the answers of these questions:
rake db:create
?有时使用 rake 创建数据库会导致问题。
您还可以在 mysql 内创建数据库
确保 mysql 位于根%PATH% 中,在命令提示符下键入 echo %PATH% 进行检查。
如果它不在你的路径中。然后在 Windows PATH 上进行快速谷歌搜索以获取说明
打开命令提示符
类型 mysql -u root -p
键入您为 root 创建的密码
创建数据库创建
数据库 simple_cms_development
完成
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
/Users/.rvm/gems/ruby-2.6.3/gems/mysql2-0.5.2/lib/mysql2/client.rb:90:in
connect'
initialize/Users/commeasure/.rvm/gems/ruby-2.6.3/gems/mysql2-0.5.2/lib/mysql2/client.rb:90:in
由于动态创建的方法而面临此错误,代码在这里
我如何临时解决这个问题只需将其注释掉
/Users/.rvm/gems/ruby-2.6.3/gems/mysql2-0.5.2/lib/mysql2/client.rb:90:in
connect'
initialize/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
How do I fix this for the temporary purpose just comment it out