【问题标题】:Rails—mysqldump error when migratingRails——迁移时出现mysqldump错误
【发布时间】:2017-10-30 04:13:27
【问题描述】:

我使用的是 Rails 4.0,每次运行迁移时都会收到此错误:

mysqldump: Got error: 1045: Access denied for user 'regan'@'localhost' (using password: NO) when trying to connect
Could not dump the database structure. Make sure `mysqldump` is in your PATH and check the command output for warnings.

我认为迁移仍然可以正常工作,但是我遇到了很多失败的测试(我刚刚收到了这个已经构建的项目)。

如何解决这个错误?

【问题讨论】:

    标签: mysql ruby-on-rails ruby-on-rails-4 migration


    【解决方案1】:

    我假设您没有在 database.yml 文件中设置用户密码。常见的情况是你在 mysql 安装中设置了密码,现在没有提供。

    您的database.yml 文件应该是这样的。

    development:
      adapter: mysql2
      encoding: utf8
      database: <my db>
      username: <my user>
      password: <my password>
      host: localhost
      port: 3306
    

    【讨论】:

    • 奇怪的是,我的数据库设置中没有任何用户或密码字段...另外,我的默认用户不使用密码
    猜你喜欢
    • 2016-10-03
    • 1970-01-01
    • 1970-01-01
    • 2017-09-26
    • 1970-01-01
    • 2012-03-10
    • 1970-01-01
    • 2013-09-28
    • 1970-01-01
    相关资源
    最近更新 更多