Why postgresql on mac asks me for password after fresh install?

后端 未结 3 1756
后悔当初
后悔当初 2021-01-02 19:21

I just installed postgresql on a Macbook with brew install postgresql. Then I try to psql, but it requires password and then show

3条回答
  •  一个人的身影
    2021-01-02 19:51

    The above did not work for me. The below steps worked for me:

    Step 1: Uninstall Postgres using the following steps:

    sudo /Library/PostgreSQL/10/uninstall-postgresql.app/Contents/MacOS/uninstall-postgresql
    

    PS: my postgres version is 10

    Step 2: Remove Postgresql user

    System Preference > userse & Groups > Unlock > remove postgresql user by clicking "-"
    

    Step 3: Remove existing databases

    rm -rf /usr/local/var/postgres/*
    

    Step 4: Install and Start Postgres using brew

    brew update
    brew install postgresql
    brew services start postgresql
    

    Step 5: Create database

    initdb /usr/local/var/postgres -E utf8
    

    You can start accessing postgres

    psql -h localhost -d postgres
    

提交回复
热议问题