Rails / MySQL2:错误 - 未知数据库

发布于 2024-11-03 03:59:01 字数 602 浏览 1 评论 0原文

我正在学习 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

带上头具痛哭 2024-11-10 03:59:01

你在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.

无声无音无过去 2024-11-10 03:59:01

我遇到了同样的错误,请在命令提示符下运行以下命令:

rake db:create 

来解决问题。

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

rake db:create 

to solve the problem.

心病无药医 2024-11-10 03:59:01

寻找这些问题的答案:

  1. 你安装了 mysql2 gem 吗?
  2. 你的 Gemfile 中提到了吗?
  3. 您是否运行了命令 rake db:create

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 ?
放手` 2024-11-10 03:59:01

有时使用 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

迷乱花海 2024-11-10 03:59:01

出现相同的错误,但原因不同

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

由于动态创建的方法而面临此错误,代码在这里

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

我如何临时解决这个问题只需将其注释掉

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文