Загрузка...

Connect Database on EC2 to spring boot In 1 GO (Step by Step)

How to Install and Connect PostgreSQL deployed on EC2 to spring boot and dbeaver | How to Install PostgreSQL in AWS EC2 | How to install PostgreSQL in EC2 instance | How to Install PostgreSQL in AWS EC2 in 3 Simple Steps [2025]

This video provides a step-by-step guide on how to connect a database on an Amazon AWS EC2 instance to a Spring Boot application. We will cover the process of setting up a PostgreSQL database on an EC2 instance, installing pgadmin 4, and configuring the database connection. The tutorial also covers the installation of PostgreSQL on an EC2 instance, setting up a Postgresql database, and connecting to it using a tool like Dbeaver. By the end of this video, you will have a clear understanding of how to connect a PostgreSQL database on an EC2 instance to a Spring Boot application, and be able to run your application with a database on the AWS cloud. The video is designed to be a comprehensive Spring Boot tutorial, covering topics such as EC2 Postgresql setup, EC2 Postgresql run, and connecting Postgresql to a Spring Boot application. The tutorial is perfect for those looking for an AWS tutorial, or a Postgresql tutorial, and want to learn how to set up a database on an EC2 instance and connect it to a Spring Boot application. The video covers the process of installing Postgresql on an EC2 instance, setting up a Postgresql database, and connecting to it using a Linux server, making it a valuable resource for those looking to learn about database setup and configuration on the AWS cloud.

---------------------
Chapters:
00:00 - 02:54 -Create and launch a EC2 instance
03:00 - 06:20 - Install the PostgreSQL 15 database
06:21- 07:52 - Connect to PostgreSQL DB from External Client
07:53- 15:00 - PostgreSQL and AWS Configuration and Dbeaver Connection
15:01- 17:10 - Spring boot Connection with PostgreSQL
---------------------

Steps to install PostgreSQL in EC2:
Step 1. Create and launch a EC2 instance

Step 2. Install the PostgreSQL 15 database
a. Update system packages
sudo yum update -y

b. Install PostgreSQL 15
sudo yum install postgresql15 postgresql15-server -y

c. Initialize the database
sudo postgresql-setup --initdb

d. Start and enable the PostgreSQL service
sudo systemctl start postgresql
sudo systemctl enable postgresql

Step 3. Connect to PostgreSQL DB and test

Switch to the `postgres` user and access `psql`
sudo su - postgres
psql

select * from pg_stat_activity;

to list all databases
\l

to connect to database postgres
\c postgres

select * from pg_stat_activity;

set password inside psql
ALTER USER postgres WITH PASSWORD 'root';
Prerequesites:
- Download and install pgadmin or dbeaver

Step 1: Connect to EC2 and verify the username database and password
sudo su - postgres
psql
ALTER USER postgres WITH PASSWORD 'root';

Step 2: Update configuration of postgres
a) update postgresql.conf to allows incoming connections on all available IP interfaces.
listen_addresses = '*'

b) update pg_hba.conf file to allow all ip to be authorized
host all all 0.0.0.0/0 md5

:q to quit and :wq to save and exit from vi

Step 3: Restart the postgresql
sudo systemctl restart postgresql
to check status
sudo systemctl status postgresql

Step 4: Update Security Group of AWS to allow 5432 port, add postgres rule in inbound rules

Step 5: Test in Dbeaver or pgadmin

Step 6: Test in springboot

spring.datasource.url=jdbc:postgresql://(EC2-Public-IP):5432/(your_database)
spring.datasource.username=postgres
spring.datasource.password=(your_password)
spring.datasource.driver-class-name=org.postgresql.Driver

# Optional: JPA settings
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect

add dependencies
a) spring-boot-starter-data-jpa
b) postgresql

#postgresqltutorial #postgres #postgresql #ec2 #aws #instance #database #cloud #cloudcomputing #awsdeveloper

Видео Connect Database on EC2 to spring boot In 1 GO (Step by Step) канала Debugger
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять