Postgres - FATAL: database files are incompatible with server

后端 未结 7 1977
半阙折子戏
半阙折子戏 2020-12-07 07:20

After restarting my MacBook Pro I am unable to start the database server:

could not connect to server: No such file or directory
Is the server running local         


        
7条回答
  •  误落风尘
    2020-12-07 08:01

    Found on internet, this solution work fine for me.

    When I tried to start postgresql server after upgrade to OS X 10.10 Yosemite, I encountered with a next problem:

    pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

    could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
    

    Okay, lets take a look into server logs:

    cat /usr/local/var/postgres/server.log

    FATAL: database files are incompatible with server
    DETAIL: The data directory was initialized by PostgreSQL version 9.2, which is not compatible with this version 9.3.5.
    

    So, we need to follow a few steps after upgrade postgresql:

    launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
    
    mv /usr/local/var/postgres /usr/local/var/postgres92
    
    brew update
    
    brew upgrade postgresql
    
    initdb /usr/local/var/postgres -E utf8
    
    pg_upgrade -b /usr/local/Cellar/postgresql/9.2.3/bin -B /usr/local/Cellar/postgresql/9.3.5_1/bin -d /usr/local/var/postgres92 -D /usr/local/var/postgres
    
    cp /usr/local/Cellar/postgresql/9.3.5_1/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
    
    pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
    
    rm -rf /usr/local/var/postgres92
    

    That's it.

提交回复
热议问题