

- Create database postgres install#
- Create database postgres 64 bits#
- Create database postgres password#
This affects the sort order applied to strings, e.g., in queries with ORDER BY, as well as the order used in indexes on text columns. lc_collateĬollation order ( LC_COLLATE) to use in the new database. The character sets supported by the PostgreSQL server are described in Section 23.3.1. Specify a string constant (e.g., 'SQL_ASCII'), or an integer encoding number, or DEFAULT to use the default encoding (namely, the encoding of the template database). encodingĬharacter set encoding to use in the new database. The name of the template from which to create the new database, or DEFAULT to use the default template ( template1). To create a database owned by another role, you must be a direct or indirect member of that role, or be a superuser. The role name of the user who will own the new database, or DEFAULT to use the default (namely, the user executing the command).
Create database postgres password#
Create database postgres install#
Install postgreSQL (if not already in your machine):.I followed the instructions, with small modifications, that I found in
Create database postgres 64 bits#
This worked for me in the standard Ubuntu 14.04 64 bits installation. It seems that this solution is not safe and not recommended. Concealing and obscuring the name of the superuser has advantages.ĮDIT: Warning: Please, read the answer posted by Evan Carroll. By keeping this disabled, you remove the risk of a brute force attack through a named super-user.And, that means that you could normally wreck havoc anyway. This normally means in order to log in as postgres which is the PostgreSQL equivalent of SQL Server's SA, you have to have write-access to the underlying data files. It's normally not password protected and delegates to the host operating system.You're supposed to have root to get to authenticate as postgres. No one is supposed to "log in" to the operating system as postgres. I suggest NOT modifying the postgres user. Or, $ grep "port =" /etc/postgresql/*/main/nf

If you don't know the port, you can always get it by running the following, as the postgres user, SHOW port Then you can login, $ psql -h localhost -d mydatabase -U myuser -p Using the SQL administration commands, and connecting with a password over TCP $ sudo -u postgres psql postgresĪnd, then in the psql shell CREATE ROLE myuser LOGIN PASSWORD 'mypass' ĬREATE DATABASE mydatabase WITH OWNER = myuser

Using createuser and createdb, $ sudo -u postgres createuser -superuser $USER Both require creating a user and a database. template1 is the admin database that is here from the start. Note that if you do a mere psql, it will fail since it will try to connect you to a default database having the same name as you (i.e. Restart (like in step 4), and check that you can login without -U postgres: The really important ones are -P -E, so that you're asked to type the password that will be encrypted, and -d so that you can do a createdb.īeware of passwords: it will first ask you twice the new password (for the new user), repeated, and then once the postgres password (the one specified on step 2).Īgain, edit the pg_hba.conf file (see step 3 above), and change "peer" to "md5" on the line concerning "all" other users: The options tell postgresql to create a user that can login, create databases, create new roles, is a superuser, and will have an encrypted password. Sudo createuser -U postgres -d -e -E -l -P -r -s (Here you can check if it worked with psql -U postgres).Ĭreate a user having the same name as you (to find it, you can type whoami): Also, you can use Nano or other editor instead of VIM. To know what version of postgresql you are running, look for the version folder under /etc/postgresql. Sudo vim /etc/postgresql/9.1/main/pg_hba.confĪnd change "peer" to "md5" on the line concerning postgres: Set the password for user postgres, then exit psql (Ctrl-D):ĪLTER USER postgres with encrypted password 'xxxxxxx' Here's what worked for postgresql-9.1 on Xubuntu 12.04.1 LTS.Ĭonnect to the default database with user postgres: The other answers were not completely satisfying to me.
