Cant initialize database on google cloud platform - postgresql

Here is the database I am trying to install (comes with 4 short instructions very easy to follow): https://github.com/toddwschneider/nyc-taxi-data
I used git clone to bring the repository down to my vm. And next I cd into it and run initialize_database.sh. Here is what happens:
pic of terminal
the password I am trying to use is the one provided by my Bitnami Launchpad, which says the admin user is postgres, but when I work on it it says kzherbert, my google account. I have tried su postgres but its not a user on the server so it doesnt work like that. I can use postgres password for psql -U postgres, which will take me to the psql terminal. Also, I have tried using my google account password as well and it does not work. What really interests me about the picture is where the shapefile is relevant and why it repeats and doesnt allow me to exit
Any and all help is greatly appreciated.

The problem is that the database you are trying to install (Unified New York City Taxi and Uber data) assumes you're installing PostreSQl from scratch instead of using the one included in the Bitnami Image.
The script you're using assumes that the user to connect the database is the same that the System User you're using to connect to your server via SSH (kzherbert in your case). However, the password you're trying to use is the one for the user postgres.
You need to connect to PG using the password Google provided you and the user postgres and the create an user kzherbert with the password you desire.

Related

Error while using createdb command postgresql on windows 10

I am a new user of PostgreSQL, and I am learning it so that I can use it with Django, so I am trying to use the createdb command to create a new database, but even though I am entering the correct password for my account, I am getting this error. I reinstalled everything and checked everything I could think of but I was not able to solve this error. So, if I can get some help regarding this issue it would be nice.
Even using the command psql, and submitting the correct password, gives the same error.
I am using Windows 10.
As far as I checked, I needed to enter the password I used while installing PostgreSQL.
By the way, I am using the latest version of PostgreSQL 14.1
The command I used:
createdb testdatabase
createdb: error: connection to server at "localhost" (::1), port 5432 failed:
FATAL: password authentication failed for user "<username_placeholder>"
So, basically, I figured the solution myself. I am just posting it here because mostly answers are available for Linux and not Windows. So, if a windows user has a similar problem, maybe this answer could help them.
So, the first thing is, if you need to open psql, use the command:
psql -U postgres
and then enter the password you used while installing PostgreSQL. Now, if you wish to do something similar to what I tried, what I mean is to use createdb command in the terminal itself, then you will have to create a new user using the same username as you do for your PC, like in my case, it is aryan.
(For example: C:\Users\aryan\).
I followed instructions from this website.
I personally used pgAdmin 4 to do it, you could also use the SQL commands themselves.
After doing everything, when I used the createdb command directly from the terminal/powershell, it asked my the password which I had used to create the other user( with the same username as my system/pc) using pgAdmin 4. That's it. This helped me out.

Database transfer from Heroku to Digital Ocean

I'm currently in the process of switching my cloud server from Heroku to Digital Ocean. However is there a way to migrate the database from the heroku server to the digital ocean one? I use postgresql for my database
I hope you already got a solution, but in case you didn’t, I’ll provide a simple guide on how I did it. I am going to assume that you have already created a postgres database on digitalocean. Also you need navigate to your project directory and log in to heroku using the heroku cli. And, you need to have postgresql installed or a psql client. Installing postgresql would do it as it comes with psql.
Step 1: Create a backup and download the backup from heroku postgres
heroku pg:backups:capture --app <app_name>
heroku pg:backups:download --app <app_name>
The first command will create a backup of your database and the second command will download it to your current directory, its a .dump file. If you would like to read more, here is an article.
Step 2: Connect to your remote (digital ocean’s) database using psql
Before you can do this, you need to go and add your machine you are connecting from to the list of database’s list of trusted sources, If you don’t, you’ll get a Connection Timed Out error. That’s because the database’s firewall doesn’t allow you to connect to the database from your local machine or resource (for security reasons).
Step 3: Import the Database
pg_restore -d "postgresql://<database_username>:<database_password>#<host>:<port>/<database>?sslmode=require" --jobs 4 -c "/path/to/dump_file.dump"
This will import your database from your dump file. Just substitute the variables will your connection parameters that you get from your dashboard. If you would like to read more, here is another article for this step.
Another thing to make clear is, sometimes, you will see some harmless error messages when running this command, but it will push through anyway. To learn more about pg_restore read this article.
And that’s it, your database has been migrated. Now, can you confirm it worked?, well, as for me, I used pgAdmin to connect to the remote database and I saw the tables and data as expected.
Hope this helps anyone with the same problem :)

How do I view a PostgreSQL database on heroku with a GUI?

I have a rails app on heroku that is using a Postgre database. My database has > 40 tables and > 10,000 rows. I would like to delete a lot of data, but it would be much easier if I was able to view and interact with it in a GUI table. I can access my data in rails console, but it's taking too long.
pgweb is a great cross-platform GUI, and it's easy to connect to your Heroku Postgres when launching from the command line.
I installed via Homebrew on a Mac (brew install pgweb), but instructions for other platforms are listed on the site. Here's how I launch pgweb connected to a Heroku Postgres DB:
heroku config:get DATABASE_URL | xargs pgweb --url
And if you want to connect to your localhost:
pgweb --host localhost
I'm a little late here, but this may help someone else who stumbles across this thread...
If you go to your Heroku app's dashboard (through the website) > settings > "Reveal Config Vars" > DATABASE_URL, and paste that URL into the browser.
I use TablePlus for database management, when I paste the link into the browser it asks if it can open TablePlus and then I can edit my production database in real time just like I would in development.
I'm not sure what pasting the URL into the browser will do if you don't have TablePlus. I assume it will request to open any other SQL management app you might have.
As slumdog wrote in the comment to your question, you can use pgAdmin, which comes with your local Postgres installation.
This article explains how to connect your remote heroku db with pgAdmin, using heroku credentials: https://medium.com/#vapurrmaid/getting-started-with-heroku-postgres-and-pgadmin-run-on-part-2-90d9499ed8fb
From the article:
"pgAdmin is a GUI for postgresql databases that can be used to access and modify databases that not only exist locally, but also remotely. For a fresh install of pgAdmin, the dashboard likely contains only one server. This is your local server...
We have to configure a new remote server with its credentials.
right click server(s) > create > server …
Fill out the following:
Name: This is solely for you. Name it whatever you want, I chose ‘Heroku-Run — On’
Under the connection tab: hostname/address. If you go back to your datastores ‘reveal credentials’, this is the host credential. It should look like --**...amazonaws.com
Keep the port at 5432, unless your credentials list otherwise
Maintenance database — this is the database field in the credentials
Username — this is the user field in the credentials
Password — the password field in the credentials. I highly advise checking save password so that you don’t have to copypasta this every time you want to connect.
In the SSL tab, mark SSL mode as require
At this point, if we were to hit ‘save’ (please don’t), something very strange would happen. You’d see hundreds if not thousands of databases appear in pgAdmin. This has to do with how Heroku configures their servers. You’ll still only have access to your specific database, not those of others. In order to avoid parsing so many databases, we have to white list only those databases we care about.
go to the Advanced tab and under db restriction copy the database name (it’s the same value as the Maintenance database field filled earlier)."
Article contains other usefull guidelines and screenshots.
Try GUI of DBWeaver.
https://dbeaver.io/
Download it, after that you can connect your heroku postgres using Database Credentials data.
You can use Heroku's hosted DB viewer on the Overview pane of your dashboard:
Create and click the Dataclip:
Dataclip GUI is fairly easy to use, we can type and customize SQL queries at the top etc.

CKAN systemadmin user and password

I installed for the first time on my OS X CKAN (And is possible ive made some mistake). Now i want to play with the UI backend but when I go in "login" section it ask me for User/password
I'm using my postgres user and user's password for access it but it give me error.
If I list the db I can see my user there but when I login it say "user doesn't exist"
So which one is the CKAN Systemadmin access?
Reading in the docs it just say, you shoudl have create this user during installation process
you can run this paster command to create a sysadmin user:
paster --plugin=ckan sysadmin add <username> --config=/etc/ckan/development.ini
For more, see http://docs.ckan.org/en/latest/maintaining/paster.html

No postgresql user created after new Windows install

I'm trying to use postgresql with Rails so I can run locally before deploying to Heroku. I installed the latest version of postgresql (9.2.4) from enterprisedb.com.
When I try to double click the database in pgAdmin III, it asks for a postgresql password. There is no Windows postgresql account in the user settings. I did notice that during my subsequent uninstallation of the application, the uninstaller referenced a service user account "NetworkService."
If I try to run the command line psql command, it asks for a password, then it complains that authentication failed for (my windows login account name). I tried entering my usual Windows account password, and that didn't work.
What's going wrong here? I've read many posts of people running into password/account issues with this database.
There is no Windows postgresql account in the user settings.
The installer for 9.2 doesn't create a postgres Windows user account. People were having too many problems with the service account password, getting confused between the service account and the postgres database account, etc. It now installs and runs as NETWORKSERVICE by default.
You will have set a PostgreSQL database password when you installed. You must log in to PostgreSQL as the postgres user with the password you gave during installation.
With the help of bma, I was able to get my Rails application running on Windows by following these steps:
Install postgresql for Windows.
Open the pgAdmin III application from the Windows Start Menu.
Click on the File menu, click Open pg_hba.conf
Browse to C:\Program Files (x86)\PostgreSQL\9.2\data\pg_hba.conf.
Double click each of the rows and change md5 to trust