MySQL连接到生产数据库

时间:2019-09-25 02:03:07

标签: ruby-on-rails ruby-on-rails-5 mysql2

我正在使用Rails 5.2和mysql2 gem。即使我在我的database.yml中使用实际的主机名进行生产配置,当我运行命令RAILS_ENV = production rake db:migrate时,它还是将主机名作为机器的本地IP地址,并显示以下错误。

 rake aborted!
 ActiveRecord::StatementInvalid: Mysql2::Error: CREATE command denied to 
 user 'username'@'lamu02rr8r9fvh7.xxx.com' for table 
 'schema_migrations': CREATE TABLE `schema_migrations` (`version` 
 varchar(255) NOT NULL PRIMARY KEY)
 /Users/egoutham/.rvm/gems/ruby-2.5.3/gems/mysql2 
 0.4.10/lib/mysql2/client.rb:120:in `_query'
 /Users/egoutham/.rvm/gems/ruby-2.5.3/gems/mysql2- 
 0.4.10/lib/mysql2/client.rb:120:in `block in query'
 /Users/egoutham/.rvm/gems/ruby-2.5.3/gems/mysql2- 
 0.4.10/lib/mysql2/client.rb:119:in `handle_interrupt'
 /Users/egoutham/.rvm/gems/ruby-2.5.3/gems/mysql2- 
  0.4.10/lib/mysql2/client.rb:119:in `query'

当我运行以下命令时,它显示了不同的错误。

  RAILS_ENV=production rake db:create
  rake aborted!
  ActiveRecord::StatementInvalid: Mysql2::Error: Access denied for user 
  'username'@'%' to database 'dashboard': CREATE DATABASE `dashboard` 
  DEFAULT CHARACTER SET `utf8mb4`
  /Users/egoutham/.rvm/gems/ruby-2.5.3/gems/mysql2- 
  0.4.10/lib/mysql2/client.rb:120:in `_query'
  /Users/egoutham/.rvm/gems/ruby-2.5.3/gems/mysql2- 
  0.4.10/lib/mysql2/client.rb:120:in `block in query'
  /Users/egoutham/.rvm/gems/ruby-2.5.3/gems/mysql2- 
  0.4.10/lib/mysql2/client.rb:119:in `handle_interrupt'
  /Users/egoutham/.rvm/gems/ruby-2.5.3/gems/mysql2- 
  0.4.10/lib/mysql2/client.rb:119:in `query'

0 个答案:

没有答案