dlbunker / ps-first-spring-boot-app

143 stars 413 forks source link

Postgres Course Setup Steps are Unclear #16

Open mojojojo94 opened 3 years ago

mojojojo94 commented 3 years ago

Hi, I am trying to follow along with your pluralsight course https://app.pluralsight.com/library/courses/creating-first-spring-boot-application. I am getting stuck on setting up the postgres db.

For example, creating the the image for the postgres db and starting it stopping it is clear but what do I do with the connection info, where is that used? also the commands are not in order of how someone would execute them to get the db set up and running for the course.

Also under "Application Data Setup" - where are those commands supposed to be executed? inside the postgres cli? outside in a terminal or a shell?

You also just gloss over this big and important step in your pluralsight course even though this course is listed as beginner on pluralsight. In your course videos you do not go over how to install and setup docker or a local postgres instance or how to create and install data in tables as well. I know you might say the focus of this course is not to know docker or postgres since we are talking about spring boot but it seems like a big oversight since use those two technologies to set up your spring boot application.

Would like some clarification of these steps for myself and for future viewers of your course.

Thank you!

edksam commented 3 years ago

Hi, I know it's a spring boot course but it's also advertised as a full stack tutorial. The database set is a big part of the setup in to be able to move on. I've spent about 3 hours trying to get it work on my machine. I think this section can be made more clearer. Thanks.

looknot commented 3 years ago

totally agree, i had to spent lots of time finding right resource and instruction to get started with Docker desktop and Postgres setup on Docker...

theartofnonso commented 3 years ago

Steps to get postgres working (Only tried this on Mac OS)

  1. Download Docker and install it, this step should be pretty straight forward
  2. Run docker create --name postgres-demo -e POSTGRES_PASSWORD=Welcome -p 5432:5432 postgres:11.5-alpine
  3. Run docker start postgres-demo
  4. You don't need to run docker stop postgres-demo since you are trying to get it up and running, except you just want to test it out. Do good to get it up and running again
  5. Leave out the DB connection for now, that will be used in the Springboot application to connect to a running instance of Postgres
  6. Download the two .sql files (create_tables.sql and insert_data.sql) you will be needing them for the last steps
  7. Run docker cp <create_tables.sql> postgres-demo:/create_tables.sql. Where code in the <> should be replaced with the full path to the create_tables.sql file
  8. Run docker exec -it postgres-demo psql -d conference_app -f create_tables.sql -U postgres
  9. Run docker cp <insert_data.sql> postgres-demo:/insert_data.sql. Don't forget the full path to the insert_data.sql file
  10. Run docker exec -it postgres-demo psql -d conference_app -f insert_data.sql -U postgres

Good luck

CHssmith2 commented 2 years ago

I agree the steps to setup are vague. I couldn't work out where the .sql files are and how to execute them within Postgres so I just copied the whole script content and pasted it directly within Postgres.

sammayel commented 2 years ago

Steps to get postgres working (Only tried this on Mac OS)

  1. Download Docker and install it, this step should be pretty straight forward
  2. Run docker create --name postgres-demo -e POSTGRES_PASSWORD=Welcome -p 5432:5432 postgres:11.5-alpine
  3. Run docker start postgres-demo
  4. You don't need to run docker stop postgres-demo since you are trying to get it up and running, except you just want to test it out. Do good to get it up and running again
  5. Leave out the DB connection for now, that will be used in the Springboot application to connect to a running instance of Postgres
  6. Download the two .sql files (create_tables.sql and insert_data.sql) you will be needing them for the last steps
  7. Run docker cp <create_tables.sql> postgres-demo:/create_tables.sql. Where code in the <> should be replaced with the full path to the create_tables.sql file
  8. Run docker exec -it postgres-demo psql -d conference_app -f create_tables.sql -U postgres
  9. Run docker cp <insert_data.sql> postgres-demo:/insert_data.sql. Don't forget the full path to the insert_data.sql file
  10. Run docker exec -it postgres-demo psql -d conference_app -f insert_data.sql -U postgres

Good luck

Step 6. should be added to the readme or to the docker image root directory

TeodorRabo commented 2 years ago

getting syntax error while running command #8

Mccaff71 commented 2 years ago

getting syntax error while running command #8

Don't download the files by right clicking the hyperlinks. Clone the project and get the files from there.

Theuser002 commented 1 year ago

Steps to get postgres working (Only tried this on Mac OS)

  1. Download Docker and install it, this step should be pretty straight forward
  2. Run docker create --name postgres-demo -e POSTGRES_PASSWORD=Welcome -p 5432:5432 postgres:11.5-alpine
  3. Run docker start postgres-demo
  4. You don't need to run docker stop postgres-demo since you are trying to get it up and running, except you just want to test it out. Do good to get it up and running again
  5. Leave out the DB connection for now, that will be used in the Springboot application to connect to a running instance of Postgres
  6. Download the two .sql files (create_tables.sql and insert_data.sql) you will be needing them for the last steps
  7. Run docker cp <create_tables.sql> postgres-demo:/create_tables.sql. Where code in the <> should be replaced with the full path to the create_tables.sql file
  8. Run docker exec -it postgres-demo psql -d conference_app -f create_tables.sql -U postgres
  9. Run docker cp <insert_data.sql> postgres-demo:/insert_data.sql. Don't forget the full path to the insert_data.sql file
  10. Run docker exec -it postgres-demo psql -d conference_app -f insert_data.sql -U postgres

Good luck

Hi, I just wanna add that in step 8, if there's not a database ready (psql: FATAL: database "conference_app" does not exist) then creating the database can be done in two ways:

  1. Directly run the docker command: docker exec -it postgres-demo createdb conference_app -U postgres.
  2. Connect to psql promt from docker docker exec -it postgres-demo psql -U postgres then inside PSQL: create database conference_app; (as instructed in the README file) Either way works.