从mysql过渡到postgress错误

时间:2016-12-17 16:00:33

标签: mysql ruby-on-rails ruby database postgresql

我想从mysql更改为postgresql。 我不关心数据所以我更改了database.yml:

default: &default
  adapter: postgresql
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.postgresql

test:
  <<: *default
  database: db/test.postgresql

production:
  <<: *default
  database: db/production.postgresql

然后运行

rails db:reset db:migrate

但我收到错误

rails aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

我已经重新启动了IDE(使用c9)和服务器,但它没有起作用。 知道如何解决这个问题吗?

@Edit启动sudo service postgresql start服务器后启动,然后运行rails db:create

我收到错误:

psql: FATAL:  role "ubuntu" does not exist

2 个答案:

答案 0 :(得分:0)

只需在您的终端中运行:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    Parse.enableLocalDatastore()

     Parse.setApplicationId("d602af8b-bba8-4f52-9c10-c367bcff49", clientKey: "https://parse.buddy.com/parse")        
    PFUser.enableAutomaticUser()
    let defaultACL = PFACL();

    // If you would like all objects to be private by default, remove this line.
    //defaultACL.getPublicReadAccess = true

    PFACL.setDefault(defaultACL, withAccessForCurrentUser: true)

    if application.applicationState != UIApplicationState.background {
        // Track an app open here if we launch with a push, unless
        // "content_available" was used to trigger a background push (introduced in iOS 7).
        // In that case, we skip tracking here to avoid double counting the app-open.

        let preBackgroundPush = !application.responds(to: #selector(getter: UIApplication.backgroundRefreshStatus))
        let oldPushHandlerOnly = !self.responds(to: #selector(UIApplicationDelegate.application(_:didReceiveRemoteNotification:fetchCompletionHandler:)))
        var noPushPayload = false;
        if let options = launchOptions {
            noPushPayload = options[UIApplicationLaunchOptionsKey.remoteNotification] != nil;
        }
        if (preBackgroundPush || oldPushHandlerOnly || noPushPayload) {
            PFAnalytics.trackAppOpened(launchOptions: launchOptions)
        }
    }


    return true
}

这是因为上次关闭计算机时,Postgresql没有正常退出(通常是由于电池耗尽)。

答案 1 :(得分:-1)

我找到了答案:

  1. sudo service postgresql start
  2. $ echo $USER
  3. $ sudo su - postgres;
  4. $ createuser ubuntu -dslP
  5. $ sudo sudo -u postgres psql
  6. 创建数据库myapp_development owner = ubuntu;
  7. 然后将我的database.yml文件更改为:

      development:
        adapter: postgresql
        encoding: SQL_ASCII
        database: cc_database
        pool: 5
        username: ubuntu
        password: password
    
  8. rails db:reset