我在运行RoR项目时遇到问题。我在运行它时遇到此错误“Mysql2 :: Error 未知数据库'simple_cms_development'“ 我不知道如何处理这个问题以及如何解决它。任何能够帮助我的人。提前致谢
这是bt database.yml文件
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: simple_cms_development
pool: 5
username: root
password: "123456"
host: localhost
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: simple_cms_test
pool: 5
username: root
password:
host: localhost
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: simple_cms_production
pool: 5
username: root
password:
host: localhost
我该如何解决这个问题?
答案 0 :(得分:4)
未知数据库意味着数据库simple_cms_development
尚不存在。如果用户root已存在,密码为123456,则可以运行rake db:create
,然后rake db:migrate
。
这些命令是从rails项目目录中的命令行运行的
答案 1 :(得分:3)
数据库是否在MySQL中创建?如果不是,您可以尝试运行rake db:create
尝试让rails为您创建它。