Cannot boot Chainlink: opening db: failed to open db: - database

When I "chainlink node start",
I get the error:
"Cannot boot Chainlink: opening db: failed to open db: failed to connect to host=/private/tmp user=myname database=: server error (FATAL: unrecognized configuration parameter "?application_name" (SQLSTATE 42704))"
I follow this youtube video: https://youtu.be/ZB3GLtQvgME?t=2017
I have a .env
but it is not reading from there.
No matter what I change on DATABASE_URL,
I get the same error.
ETH_URL=wss://kovan.infura.io/ws/v3/
FEATURE_EXTERNAL_INITIATORS=true
LOG_LEVEL=debug
ETH_CHAIN_ID=42
MIN_OUTGOING_CONFIRMATIONS=2
LINK_CONTRACT_ADDRESS=
CHAINLINK_TLS_PORT=0
SECURE_COOKIES=false
ALLOW_ORIGINS=*
DATABASE_URL=postgresql://localhost:5432/kovan_demo?sslmode=disable
DATABASE_TIMEOUT=0
FEATURE_FLUX_MONITOR=true
MINIMUM_CONTRACT_PAYMENT=0
CHAINLINK_DEV=true

The database parameters are set via environment variable

As Richard said, you need to set DATABASE_URL as an environment variable. For some reason, the chainlink client cannot read file .env and set the environment variable as expected.
The way how I solve the problem is to set DATABASE_URL as an environment variable explicitly by command:
export DATABASE_URL=postgresql://<usrname>:<passswd>#localhost:5432/chainlink_node?sslmode=disable
You can find all configurations of Chainlink node here.
Hope it helps.

The format to connect to the database is the following:
DATABASE_URL=postgresql://$USERNAME:$PASSWORD#$SERVER:$PORT/$DATABASE
I always follow this steps to create the database:
sudo -u postgres psql
create database $DATABASE;
create user $USERNAME with encrypted password '$PASSWORD';
grant all privileges on database $DATABASE to $USERNAME;
Just change the variables
sudo -u postgres psql
create database chainlink;
create user username with encrypted password 'pass';
grant all privileges on database chainlink to username;
And then:
DATABASE_URL=postgresql://username:pass#localhost:5432/chainlink?sslmode=disable
I don't recommend at all this credentials for production.

Related

psql: error: FATAL: password authentication failed for user "Davinci"

Im trying to setup postgres database for my django project, so i donwnloaded the installer together with the pgadmin. i set a default password when installing and i used it to login to the pgadmin and it worked, i now wanted to run so cli commmand, so i added postgres to path in my system enviroment variable in other to be able to run it on the cli and it works, i mean the system recognise the commands but im getting errors which i think its comming from the database itself. i have no idea about this error, this is my first time using it.
PS: it asked for my system user password and i entered it, then i got the error bellow.
C:\Users\Davinci>psql
Password for user Davinci:
psql: error: FATAL: password authentication failed for user "Davinci"
Try running psql -U postgres and then inserting the password you chose at pgadmin.
User postgres is the default, but it seems like Windows is trying to run psql -U Davinci when you type only psql, so you have to specify which user (-U for user / postgres for the username) when trying to connect.

How can I run pg_dumpall with Heroku?

How can I use pg_dumpall with Heroku? The default "database backup" feature from Heroku is pg_dump with the click of a button, which doesn't include roles, so I want to do pg_dumpall ... I'm trying pg_dumpall -h myherokuurl.compute-1.amazonaws.com -l mypassword -U myUser > dump.sql
I'm getting this error:
pg_dumpall: error: query failed: ERROR: permission denied for table pg_authid
pg_dumpall: error: query was: SELECT oid, rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolconnlimit, rolpassword, rolvaliduntil, rolreplication, rolbypassrls, pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, rolname = current_user AS is_current_user FROM pg_authid WHERE rolname !~ '^pg_' ORDER BY 2
My first thought was to create a new user with the correct privileges. So, I logged using heroku pg:psql DATABASE -a my-app-name then tried create user myUser with password 'mypassword' but got the error ERROR: permission denied to create role
I'm honestly not sure what's going on I'm kind of just guessing. Any troubleshooting ideas would be appreciated! (in the meantime I'm just trying to learn more about Postgres)
If your problem is just about the pg_authid catalog, you should be able to use recent versions of pg_dumpall with the --no-role-passwords option.
This commonly works in hosted environments where pg_authid is inaccesible, e.g. on AWS. The only downside is that the passwords of Postgres users will be missing from the dump.
However, you appear to have a more limited, perhaps shared environment, where you can't even create new Postgres users. I am not certain if there is any chance to get pg_dumpall working there.

Cant connect to oracle db in docker with squirrel-sql

I tried to connect to oracle db 11 in docker (https://hub.docker.com/r/sath89/oracle-xe-11g/).
Started docker with command:
docker run -d -p 8080:8080 -p 1521:1521 -e DEFAULT_SYS_PASS=sYs-p#ssw0rd sath89/oracle-xe-11g
From this description:
hostname: localhost
port: 1521
sid: xe
username: system
password: oracle
made an url - jdbc:oracle:thin:#192.168.99.100:1521:xe
With squirrel-sql have an error:
class java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-12705: Cannot access NLS data files or invalid environment specified
But if I try to connect with SQLplus thats ok:
docker exec -ti oracle_id sqlplus bash
sqlplus
The SquirrelSQL needs to have some NLS variables set before logging in. For the Docker connection, note that you have "bash" at the end of your command. This not only tells the connection that you'll be using bash shell, it sets up the environment to connect using the bash_rc, (and possibly a profile, too). You're coming from your local machine vs. an SSH, so the local machine is being used instead of the SSH.
I believe there is a squirrel-sql.bat file that could unset and then set the environment or better yet, let's just unset it in the registry and let the local connection take its course:
On your Windows maching:
Do a search for an NLS_LANG subkey in the registry: \HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE, rename it, save the change, reboot and retry.
I’m not familiar with Squirrel SQL, but you may also be missing a proper set up of the jar files. Look and see if your jar files are configured correctly, depending on your version, its going to look something like this:
%Oracle_\jdbc\lib\ojdbc.jar

Run psql and pg_dump without password and without using sudo -u postgres

I am trying to copy one table from one database to another:
sudo -u postgres pg_dump -t _stats db30 | psql db8;
However, I always get asked for a password, and I do not know what it is. Is there a way to do this without pg_dump? Is there a way so that I can not be asked for a password when I run psql?
Note, to get into postgres I have to run sudo -u postgres psql instead of psql
User management and permission on a postgres server is a complex topic, but you have probably only a server installed on your desktop and use it only on localhost, so security is not so important.
You have to do 3 steps:
1) Edit the pg_hba.conf file and restart the server
2) Login with psql and set a password for the user postgres
3) Edit (or create) the file ~/.pgpass
NOTE: you could use the authentication method trust in pg_hba.conf and avoid the step 2 and 3, but this is really TOO permissive, and you shouldn't use it, even on localhost.
The pg_hba.conf file
To understand the file pg_hba.conf please read here: http://www.postgresql.org/docs/9.4/static/auth-pg-hba-conf.html
Basically, if you server is on localhost and security does not matter, you can simply allow all user to connect with md5 authentication method.
If you don't know, where this file is, use this command:
locate pg_hba.conf
Probably is in /etc/postgresql/9.3/main/pg_hba.conf or similar.
Edit the file and change the already existing lines so (at end of the file):
local all all md5
host all all 127.0.0.1/32 md5
Now restart the server with
sudo service postgresql restart
Set a password for the user postgres
First login in psql:
sudo -u postgres psql
Now, within psql, change the password:
ALTER USER postgres PASSWORD 'your-password';
The pgpass file
Now you can login in psql with psql -U postgres (without sudo -u postgres) but have to enter the password. To avoid to digit the password every time, you can set up the pgpass file. If does not already exist, you must create a file named .pgpass in your home directory. The file must be owned by your user and be readable only by your user:
chown $USER:$USER ~/.pgpass
chmod 600 ~/.pgpass
Now write in the file those lines:
localhost:5432:*:postgres:your-password
127.0.0.1:5432:*:postgres:your-password
Alternately you can use the environment variable PGPASSWORD: http://www.postgresql.org/docs/9.4/static/libpq-envars.html
Ready. Now you can login in postgres with psql -U postgres without enter the password.

Unable to connect to postgres database through heroku

I have a postgres database that I created through heroku. I am trying to access it through psql with the command:
cse-190-fortune matanvardi$ psql "dbname=dccemfsa6camml host=ec2-54-235-152-226.compute-1.amazonaws.com \
user=tfmfbqxqjznsbl password=********* port=5432 sslmode=require"
I get this error:
psql: could not connect to server: Operation timed out
Is the server running on host "ec2-54-235-152-226.compute-1.amazonaws.com" and accepting
TCP/IP connections on port 5432?
I've cloned the repository and I'm logged in, I simply cannot figure out what is wrong here. Any help would be greatly appreciated.
To access your Heroku database from the command line use the command:
heroku pg:psql
Edit:
I ran your command from my machine. If course I don't have your password but I got:
$ psql "dbname=dccemfsa6camml host=ec2-54-235-152-226.compute-1.amazonaws.com user=tfmfbqxqjznsbl port=5432 sslmode=require"
Password:
psql: FATAL: password authentication failed for user "tfmfbqxqjznsbl"
Which means I was able to connect, which is farther than you got. It must be a problem with your network setup.

Resources