A qusetion about the command of postgreSQL - psql

I am trying to install the BIGSdb, but I failed to create databases.
I use the following command:
createdb bigsdb_test_seqdef
psql -f seqdef.sql bigsdb_test_seqdef
But, I always get the following error:
How can I fix this problem?

Related

ThingsBoard installation failed! On Ubuntu

I am trying to install thingsboard PE instance on Ubuntu 18.04.3 LTS
while I run this command
sudo /usr/share/thingsboard/bin/install/install.sh --loadDemo
I am facing the following error
Error: Could not find or load main class org.springframework.boot.loader.PropertiesLauncher
ThingsBoard installation failed!
the thingsboard.log file is not present in /var/log/thingsboard
Can anyone please suggest me what's the reason for this error?
Make sure the thingsboard database does actually exist. I had the same error. I did follow the instructions, but possibly the CREATE DATABASE was not followed by ';' or it needed to be started.
Restart the ubuntu server.
Log in and log onto PSQL: psql -U postgres -d postgres -h 127.0.0.1 -W
Check for existence of the database: \list
If it does not exists, run: CREATE DATABASE thingsboard;
Run \list again and make sure it exists. Quit by running \q.
Re-run the demo create script: sudo /usr/share/thingsboard/bin/install/install.sh --loadDemo
Happy Thing-ing.
Along with the above as Antony Horne has suggested, also you can remove the ThingsBoard related directories under /tmp/. Remove and recreate the 'thingsboard' database. Make sure to set the password as 'postgres'. Then re-run the command
/usr/share/thingsboard/bin/install/install.sh --loadDemo
It should be fine.
Though after that, when I tried to run the 'thingsboard' as
service thingsboard start
Its is not working as 'thingsboard' is unrecognized. Couldn't solve that yet.

Hyperledger Explorer

I have installed all prerequisites for setting up the hyperledger Explorer but when I start it, I got the following error in log file:
And my config.json file is this:
Postgres' command also done:
1: https://i.stack.imgur.com/eTpSY.png
2: https://i.stack.imgur.com/IocQU.png
You're database setup is not done correctly, run these commands one by one.
Database setup
Connect to PostgreSQL database
sudo -u postgres psql
Run create database script
\i app/db/explorerpg.sql
\i app/db/updatepg.sql
Run db status commands.
\l view created fabricexplorer database
\d view created tables
Actually it postgres database error ...
In your error its clearly said that the chaincode_id doesnt exit ... so this is the problem .
if you want check what column are existed in the transaction table just follow below step
cd blockchain-explorer/app/persistence/postgreSQL/db
sudo -u postgres psql
\d transactions
check the corresponding column chaincode_id exist or not (it wont exist now ,Thats why you got this error)....
Solution for this type error
If you got any error like this first just go to the blockchain-explorer/app/persistence/postgreSQL/db directory
There you can see two file explorerpg.sql and updatepg.sql open this two file and check the corresponding column if existed on any of this file or not. If not you better to download explorer another version which contain the corresponding columns either of this two file mentioned above.
if existed just run below command on ubuntu
cd blockchain-explorer/app/persistence/postgreSQL/db
sudo -u postgres psql
\i explorerpg.sql
\i updatepg.sql
Once done this command just check the column "chaincode_id " is created or not by
\d transactions
it will list all column just check it on.
if the chaincode_id is exist run the explorer again ....

-bash: pg_dump: command not found

I'm trying to pull a production database locally for my rails app. My local postgres version was too low so I needed to update to Postgresql 9.6.5 from 9.4.1.
I installed Postgres 9.6.6 via Homebrew as such:
brew install postgresql#9.6
Then ran:
brew services start postgresql#9.6
However, when I try to do pg_dump I get -bash: pg_dump: command not found.
I also tried updating my path as such:
export PATH="/usr/local/Cellar/postgresql\#9.6/9.6.6/bin:$PATH"
Any idea what I need to do to get pg_dump to work?
Adding this to my ~/.bash_profile did the trick:
export PATH=/usr/local/Cellar/postgresql\#9.6/9.6.6/bin:$PATH
For those who have this issue on Mac even though Postgres path is correctly added on your .bash_profile I found that running pg_dump directly from the Terminal does the job.
Just open your Terminal and type:
pg_dump -U username your_database > db_dump.bak
I tried the ff approach and I got the same error:
sudo su - postgres
pg_dump -U username your_database > db_dump.bak
bash: pg_dump: command not found
If you installed PostgreSQL by pgadmin4 in Mac, you could find the pg tool in
/Library/PostgreSQL/{version}/bin/
Couldn't get path to work in Cygwin but could browse to my pg bin directory (C:\Program Files\PostgreSQL\9.6\bin) and run it directly from there.
For windows what worked for me is to add the Postgres to global vars from env, not ~/.bash_profile,
Go to Edit the system environment variables
Then Environement variables
Then Path then add the location of bin of postgres in my case C:\Program Files\PostgreSQL\14\bin\
Click ok on each open window
Close and reopen your visual code
Run your command
See Setting Windows PATH for Postgres tools for more details

Ruby on Rails 4: when type rails server , got error message PG::ConnectionBad

I am new to Ruby on rails. I've created basic demo apps by tutorial learning by examples.
First it working fine, one week later i got error when type rails s,
Error
PG::ConnectionBad
could not connect to server: No such file or directory Is the server running
locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
I am using PostgreSQL database.
I am on MAC OS X 10.8.5
I have found similar questions on SO, but they are experiencing at some advance stage and thus involves some advance solutions.
when type
which psql
/usr/local/bin/psql
It seems upgrading your OS has changed the permissions on the directory where Postgres keeps its data.
Run
sudo chown -R sabir:staff /usr/local/var/postgres
to make your user account the owner of that directory. Enter your password when it asks for it; you will not see the characters as you enter them.
The homebrew version of Postgres includes the ability to start automatically. To check whether your installation does, run
ls -l ~/Library/LaunchAgents/
You should see a line ending with homebrew.mxcl.postgresql.plist. If you do not see this line, run
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
in order to have it start automatically.
Finally, run
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
to make sure Postgres is active now. Confirm by typing
psql -l
When you install postgres using homebrew, than maybe you just started it manually in foreground. So after closing the terminal window postgres was not running anymore.
I'd suggest to do the following steps:
Check if postgres is running by grepping the process list: ps aux | grep postgres
if it's running try to sudo kill -9 {POSTGRES_PID}
if not running, use brew info postgres to see how to start it manually (or on startup etc.)
start postgres with the result from homebrew - in my case postgres -D /usr/local/var/postgres
I hope, that will help you out.
If you installed postgres on another basis, I can change my answer accordingly.

How to specify which postgres copy for rails to use

How do I specify which version of postgres rails use? When I run puma and go to localhost:3000 I get a an error
PG::ConnectionBad
fe_sendauth: no password supplied
I think the copy being used may be the manual install 9.3, as when I run:
/usr/local/Cellar/postgresql/9.4.1/bin/pg_ctl -D /usr/local/var/postgres start
I get the error:
stgres start
server starting
LOG: skipping missing configuration file "/usr/local/var/postgres/postgresql.auto.conf"
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.3, which is not compatible with this version 9.4.1.
I found three copies of pg_hba.conf on my system:
/Library/PostgreSQL/9.3/data/pg_hba.conf
/Users/lasernite/Library/Application Support/Postgres/var-9.4/pg_hba.conf
/usr/local/var/postgres/pg_hba.conf
The first one I believe was from a manual install at some point. The second one is probably just some supporting copy/ignorable, and the third one is a homebrew install.
How can I make rails use the homebrew postgres install, even if it means wiping the local database? Which is fine so long as the production on heroku is instact.
I've been stuck for several days on reconfiguring my development environment from sqlite to postgres, which is very problematic as I have a production db and site live now, which is forcing me to do some code pushes without being able to verify functionality locally, but for the most part has totally crippled my ability to do any development.
Please help me!
It looks like the problem is that you're starting 9.4.1 when the database was created by 9.3.x.
The version of posgres that Rails uses should be whichever one is running. So if you want to start postgres in version 9.3.x, then you should start that version. But you have to specify the correct path for that version.
What output do you get for these?
> initdb --version
> pg_ctl --version
> postgres --version
> psql --version
It should all be the same. If it says 9.4.x and you want to use that version, then you can re-init the database like so: initdb -D /usr/local/var/postgres-4.1 and then you can start postgres postgres -D /usr/local/var/postgres-4.1. Doing it this way, you'll probably lose your local database since it sounds like that data was created by 9.3.x.
Alternatively, if those output 9.3.x, then you should just be able to use the commands without the full path to the binary: postgres -D /usr/local/var/postgres.
If you're using 9.4.x and you want to keep using 9.3.x, then try which postgres. It's probably pointing to /usr/local/bin. Then make sure that that is just a link to the homebrew version. ls -la /usr/local/bin | grep "postgres ->".
If you're using the homebrew version, you can do brew switch postgres 9.3.x to tell homebrew to use that version. Then you should be able to start postgres with postgres -D /var/local/var/postgres.

Resources