我想从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
答案 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)
我找到了答案:
sudo service postgresql start
$ echo $USER
$ sudo su - postgres;
$ createuser ubuntu -dslP
$ sudo sudo -u postgres psql
然后将我的database.yml文件更改为:
development:
adapter: postgresql
encoding: SQL_ASCII
database: cc_database
pool: 5
username: ubuntu
password: password
rails db:reset