Password when executing postgresql command

Asked

Viewed 506 times

0

Good morning,

I am trying to create a database in postgresql via terminal in windows. But ask me for a password every time I give the command. I tried to use the password of the user postgres but does not accept. Someone can help me?

inserir a descrição da imagem aqui

  • You need to change your user "Scroll" that belongs to that database. That is, change the user permission, so as not to always ask for the pass.

  • Marcelo, you need to provide more details, such as the command used and the parameters informed. For example, you have the option to tell which user you want to perform the command with, which could make a difference in the time you provide the password so that it matches the user who will execute the command.

  • I’m trying the following command: create user -U adempiere adempiere

  • @Rafaelaújo in the image above has the command, other details, is that the client and server are on the same machine that is a Windows 7 x64 and the postgres version is 9.4

  • Marcelo, the command to create the bank is createdb (https://www.postgresql.org/docs/current/static/app-createdb.html). For the example you gave, it would be createdb -U adempiere adempiere. The password to be informed, then, is that of the user adempeiere which should already exist in the database.

  • @Rafael Araújo agree that in order to create the database the user must pre-exist, but when I try to add the user (first step), it asks for the password

  • @Marceloprate, then notice that you have a problem with the previous command. The createdb command cannot be executed using a user you want to create. The use of -U adempiere means you want to connect using the user Adempiere and that is why it does not accept the password of postgres. To use the user postgres in the creation of the new user, the command is createuser -U postgres -d -l adempiere (allows you to login and create database).

Show 2 more comments

1 answer

1


To create a new usuario/role in the PostgreSQL, you need the command CREATE ROLE, for example:

CREATE ROLE adempiere LOGIN NOSUPERUSER INHERIT CREATEDB CREATEROLE;

To create a new usuário/role through the terminal of Windows you can use the utility pgsql, look at you:

psql -U postgres -c "CREATE ROLE adempiere LOGIN NOSUPERUSER INHERIT CREATEDB CREATEROLE;"
  • managed to create user with your last command. Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.