I installed postgresql on mac using brew. I wasn't asked about for the
password for postgresql during the installation.
That's normal because brew
doesn't need or create any postgres
account.
The PostgreSQL processes run under your own account. The other 3 answers so far are wrong in this regard.
See the output of brew info postgres
for information.
To create a new database account, you may launch, from your own OS account:
/usr/local/bin/createdb someusername
or within psql:
/usr/local/bin/psql -d postgres
and then as an SQL command: CREATE USER someusername PASSWORD 'somepassword';
This should work because brew has normally created at initdb
time:
- a database superuser account with the same login as your OS account (seems to be
alex
in your case)
- a database named
postgres
that may be used to log info for administrative tasks such as creating a user.
The point of using the full path /usr/local/bin
is to reach the commands provided by brew
, as opposed to the commands with the same name that come with the system and are located in /usr/bin
or the commands with the same name that are potentially installed by other PostgreSQL providers, such as postgres.app or macports or entreprisedb. There are 5-6 competing and incompatible ways of getting postgresql installed on Mac OS X.
EDIT: the newer versions of MacOS X desktop edition no longer have the postgres client-side commands pre-installed. This seems to be the case at least since MacOS X 10.10 (Yosemite) and possibly 10.9.