First step#
brew install postgresql@14
brew services restart postgresql@14
psql postgres
If everything works, congratulations! Now close this tab and enjoy your life. If not, please continue reading.
Debugging#
In M1 Mac, brew services log exists in the following path.
cat /opt/homebrew/var/log/[email protected]
Checking the log here, and it says:
postgres: could not access directory "/opt/homebrew/var/postgresql@14": No such file or directory
Run initdb or pg_basebackup to initialize a PostgreSQL data directory.
Okay, seems like our database is missing. Let's create one at the expected directory.
initdb --locale=C -E UTF-8 /opt/homebrew/var/postgresql@14
brew services restart postgresql@14
Now everything should work.
In case you need a database user.
/opt/homebrew/bin/createuser -s <username>
psql -U <username>
## and in the psql shell, run \password to set a password
postgres=# \password