Create user on Postgres 9.5 using FreeBSD and Vagrant - postgresql

I am trying to create a user in Postgresql 9.5 on FreeBSD 11. I am also trying to automate the whole thing with Vagrant and I have almost succeeded except for the creation of the user. I am using the createuser command with a password, and with that, I have attempted to use expect command in order to send the password to the prompt but I continue to receive the following error message:
"default: createdb: could not connect to database template1: FATAL: role "root" does not exist"
Here is the code sample that I am using:
# Create the database and the user
PASS=password
expect << EOF
spawn createuser -sdrP capstone
expect "Enter password for new role:"
send "${PASS}\r"
expect "Enter it again:"
send "${PASS}\r"
expect eof;
EOF
I am not too sure what else to try in regards to overcome this error, any help would be appreciated.

Do not run this script as root.
By default user "pgsql" has the permissions.
Switch to user:
su -l pgsql
Then run your expect script.

Related

postgres is not in the sudoers file. This incident will be reported

If the error occurs when trying to create PostgreSql Role This error occurs because you are inside the postgresql.
You need to change to root user, for that you need to type in the terminal,
su root
Next run the command,
sudo -u postgres createuser --interactive
Your question is hard to follow, as it reads like you are just quoting someone else, but it isn't clear who or why.
The way this usually happens to me is that initially I am logged in as a user who does have sudo powers (my normal daily user account), but then I change into "postgres" Linux user by executing sudo su - postgres. But once there, I then try to execute some sudo command, but since logged in as postgres and postgres does not have sudo powers, I get this error. I fix the error by exiting the shell which is logged in as postgres, and so dropping back to my regular account, before repeating the sudo attempt.

postgres 13, terminal(psql) closes after asking for password

I've just installed postgres 13 and am trying to learn it for the first time. (windows) During the installation process I was prompted to create a password.
Now when I try to open up the psql terminal I'm immediately prompted enter a password.
After I enter the password the terminal just closes for some reason and nothing further happens.
From what I gather on-line, some are saying this is due to postgres using my 'windows user login' as it's user?
I'm not sure what the fix is for this or how to go about using postgres from here.
Does anyone have any insight?
Explain it to me like I'm 5 please.
As talked about in the comments, the solution was to open psql.exe from cmd.
The reason the terminal was closing was due to a password Auth error.
From there I was able to call the .exe with the appropriate options.
eg
psql.exe -d postgres -U postgres
I found that from this answer:
In PostgreSQL why does command line window disappear when I press Enter after entering my password?
The problem was that the shell will by default try and use the windows user as the log in ID, and the password you type will be incorrect for that log in ID.

How to create super user in Postgres

I am new to Saleor and I followed all the step in the documentation. However I can't seem to create a new user. I have install PostgreSQL 11 using a .dmg file downloaded from the official website.
Every time I run createuser --superuser --pwprompt <username> I get bash: createuser: command not found.
If I try to install PostgreSQL with "brew install Postgres" and then run createuser --superuser --pwprompt <username>, I get asked for password twice for the new role then a third time which I have tried to many time to enter with no success. I get the error FATAL: password authentication failed for user <terminal username>.
I'm using VS code

Openerp 7.0 error database

i have a problem with Openerp, can you help me please ?
ERROR ? openerp.sql_db: Connection to the database failed
Traceback (most recent call last):
File "/opt/openerp/server/openerp/sql_db.py", line 440, in borrow
result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
OperationalError: fe_sendauth: no password supplied
Check your /etc/openerp/openerp-server.conf and make sure you have at least the following options set:
db_host = (usually localhost)
db_port = (usually 5432)
db_user =
db_password =
Try connecting to your database manually by running:
psql -d postgres -U <YOUR DATABASE USERNAME> -W
If this works (you should get a prompt like "postgres=>", exit it by pressing ctrl+d) but the error is still there in OpenERP, its probably because you run Ubuntu/Debian and you just installed your OpenERP package. The error appears because the init script are not able to kill the first openerp Python process started by dpkg automatically after the package installation. To fix this, run:
# ps aux|grep openerp
You will see a line that looks something like this:
openerp 14438 0.3 0.8 235096 69060 ? Sl 03:23 0:00 /usr/bin/python /usr/bin/openerp-server --config=/etc/openerp/openerp-server.conf --logfile=/var/log/openerp/openerp-server.log
The first number is the pid of the Python process. Kill the process by running:
kill -9 14438
Then restart your openerp server again by running:
/etc/init.d/openerp restart
Your openerp-server.conf should now be re-read by OpenERP and the error should disappear.
Search Google and Stack Overflow for "fe_sendauth: no password supplied".
Your PostgreSQL is set up to require a password for the (address,database,user) combination you're connecting with and you aren't sending a password.
You can learn more by reading the Client Authentication chapter of the PostgreSQL documentation.
create a postgres user using this command.
make sure the user is named same to your system user.
sudo su postgres
createuser -d -S -R <your system user>
psql
alter user <your system user> with password <your password>;
Hope it will resolve your issue to establish connection with database.
Go to your opererp-server.conf and look for addons_path. Make sure you have /openerp/addons and /openerp/web/addons. if you have something else just take it off and restart your server. It will work.

mapnik gis authentication error during boot

I am using tilelite to serve up maps. I need it to run at the time the server is started. I have built a script that runs the following command at startup:
/usr/local/bin/liteserv.py /home/Uname/bin/mapnik/my_osm.xml --caching --debug=False
The process is failing with:
FATAL: Ident authentication failed for user "user_name" (encountered during parsing of layer 'leisure')
According to this page:
http://wiki.openstreetmap.org/wiki/Mapnik#Authentication_failed
I ran the following command:
./generate_xml.py osm.xml my_osm.xml --accept-none --dbname gis --symbols ./symbols/ --world_boundaries ./world_boundaries/
Now I get:
RuntimeError: PSQL error:
FATAL: Ident authentication failed for user "root" (encountered during parsing of layer 'leisure')
I am really new to postgres so could someone give me some very simple insructions on how to fix this.
If you call ./generate_xml.py --help you will see the various options. One of them is --user. If you do not supply it and also pass --accept-none then no specific user will be written into the Mapnik XML, which means that when Mapnik attempts to connect to the postgres database the current user will be used. So, if you run that script as root, 'root' will be used.
So, you need to either run that script as a unix user that can connect to postgres, or you need to go back and regenerate the XML and embed the name of a user that can connect to postgres. The latter is likely easier. Here is what I would do:
Assuming your normal unix use is named 'heman' do:
$ sudo su postgres
$ createuser heman # make superuser
$ exit
$ ./generate_xml.py osm.xml --accept-none --user heman --dbname gis --symbols ./symbols/ --world_boundaries ./world_boundaries/
$ liteserv.py osm.xml --caching --debug=False
More details on postgres and how to enable "trust" so that you can connect as the "postgres" user here: http://dbsgeo.com/foss4g2010/html/troubleshooting.html#troubleshooting-postgresql-connections