用于显示数据的数据库似乎与我可以在 rails 控制台中使用的数据库不同。
我试过跑步rails dbconsole
,我得到:
Couldn't find database client: sqlite3. Check your $PATH and try again.
我的测试和开发数据库适配器是 SQlite3,我的生产适配器是 MYSQL。
我需要我的 rails 控制台来连接到我的生产数据库。
用于显示数据的数据库似乎与我可以在 rails 控制台中使用的数据库不同。
我试过跑步rails dbconsole
,我得到:
Couldn't find database client: sqlite3. Check your $PATH and try again.
我的测试和开发数据库适配器是 SQlite3,我的生产适配器是 MYSQL。
我需要我的 rails 控制台来连接到我的生产数据库。
如果要连接到生产数据库,则需要在执行or命令之前将RAILS_ENV
环境变量设置为。production
console
dbconsole
“Rails 控制台”和dbconsole
命令引用不同的东西:
如果要直接连接到数据库以执行 SQL 语句,请使用
$ RAILS_ENV=production ./script/rails dbconsole
如果您尝试加载“Rails 控制台”,即可以访问 Rails 环境的交互式 Ruby shell,请运行
$ RAILS_ENV=production ./script/rails console
请尝试以下命令。
RAILS_ENV=production rails c