我以此下载了远程mysql转储
mysqldump -u username -p -h remote.site.com DBNAME > backup.sql
之后,当我尝试启动服务器时出现错误:
`rescue in mysql2_connection': Unknown database 'my_database' (ActiveRecord::NoDatabaseError)
我是否需要将下载的转储明确地移到某个地方,或者足以将其下载到主目录中?
config / database.yml
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password: root
socket: /var/run/mysqld/mysqld.sock
development:
<<: *default
database: my_database
test:
<<: *default
database: my_database_test
production:
<<: *default
database: my_database_37
答案 0 :(得分:1)
我知道您想将转储的数据库导入本地环境。首先,让我们创建数据库
rails db:create # or rake db:create previous rails 5
然后,导入您的转储
mysql -u username -p dbname < backup.sql