LCWD LogoLearn Code With DurgeshLCWD
HomeCoursesBlogsContact
About LCWDAbout Durgesh Tiwari
Flex Box Hero
LearnCodeWithDurgesh Logo

Learn Code With Durgesh

Offering free & premium coding courses to lakhs of students via YouTube and our platform.

Explore

  • About Us
  • Courses
  • Blog
  • Contact
  • FlexBox Game

Legal

  • Privacy Policy
  • Terms & Conditions
  • Refund Policy
  • Support

Contact

  • 📞 +91-9839466732
  • [email protected]
  • Substring Technologies, 633/D/P256 B R Dubey Enclave Dhanwa Deva Road Matiyari Chinhat, Lucknow, UP, INDIA 226028
© 2025 Made with ❤️ by Substring Technologies. All rights reserved.
Deploying Spring Boot with Mysql on DigitalOcean droplet

Deploying Spring Boot with Mysql on DigitalOcean droplet

By durgeshkumar8896 • Thu Sep 22 2022

Deploying Spring Boot with Mysql on DigitalOcean droplet

Digital Ocean logo

1. Login to Digital Ocean account

2. Create a project

3. Create a new droplet

Create a new key pair and add to the droplet key section.

When droplet creation finishes then reset the password for root. It is mandatory.

4. Login using the console . I prefer to login using ssh.

                

 ssh -i  [filekey] root@ipaddress

        5.     Before doing anything run update command:

sudo apt update

 

 


Installing MySQL

1. After update command run command below

sudo apt install mysql-server               

   Press Y if prompted and it will install mysql on the machine

2. Start the mysql server by running the command

sudo systemctl start mysql.service 

3. Check the status all fine or not.             

sudo systemctl status mysql.service

This is show Active(running) status

 

4. Now it's time to configure mysql

5. Alter the root user password  first

sudo mysql

ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_passowrd BY ‘password’



6.  Type exit.

7.    Now Login with root user      

sudo mysql -u root -p 

8.  Now run mysql secure script

sudo mysql_secure_installation   

Provide the answer of prompted questions

9. Creating a dedicated user so that we can access this user outside the machine also.

mysql -u root -p

CREATE USER 'username'@'host' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO ‘user’@'host’;

FLUSH PRIVILEGES;

exit

 

10. Restart the mysql server so that changes reflect.

sudo systemctl restart mysql.service

11. Finally done with mysql installation and now we can use mysql.


Let's Connect mysql to our local workbench

1. First , convert public key to pem

ssh-keygen -p -m PEM -f [yourpublickey]

Type this command to convert , make sure to  backup the key first.

2. Open the workbench and add a new connection.

3.  For Connection Name, enter any name you’d like that helps you identify the connection you’re making later. 

4. Change the Connection Method to Standard TCP/IP over SSH.

5. For SSH Hostname, enter your droplet IP address. If your server accepts SSH connections on a different port, enter the IP address, followed by a colon and port number.

6. For SSH Username(root), enter the username you use to log into the server via SSH.

7. For SSH Password, enter the password you use for your SSH user. If you use public keys instead of passwords, select an SSH key for authentication.

8. For MySQL Hostname and MySQL Server Port, use the default values.

HostName: 127.0.0.1
Port: 3306

9. For Username, enter the MySQL username.

10. For Passwords, you can either enter the password or leave it blank. If you do not store the MySQL password in MySQL Workbench, a prompt will request the password each time you attempt to connect to the database.

11. Choose Test Connection to ensure your settings are correct.

12. Choose OK to create the connection.

Create your database using mysql work now.


Lets install Java and Deploy Spring boot

1.On you droplet console type command:

sudo apt install openjdk-11-jre-headless

sudo apt install openjdk-11-jdk-headless

I am installing java 11 

Important: Using above command java 11 get installed but javac is not.

There is no need to install javac because we are going to just run application not compile or build but if you want you can install

2. Build your spring boot application with prod profile and server config details in your properties files.

3. Upload this jar to droplet machine folder using FileZilla in our case we created new folder with projects

4. Now Create two script with following commands.

start.sh

#!/bin/bash

nohup java -jar /projects/blog-app-apis-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod > /projects/log.txt 2>&1 &

echo $! > /projects/pid.file

stop.sh

kill $(cat /projects/pid.file)

Important : Change your folders path and filename accordingly.

5. Run start script 

sudo ./start.sh

Congratulation project is now running on you given port in project config file.

You can now test it on 

http://ip-adress:portnumber

 

Share this article ...

💬WhatsApp📘Facebook💼LinkedIn🐦X

Trending Blogs...

The 5 ChatGPT Prompts That Saved Me From Burnout

The 5 ChatGPT Prompts That Saved Me From Burnout

Here’s what I discovered: It wasn’t about working less. It was about working smarter. When I gave ChatGPT the right prompts, everything changed. Here are the 5 prompts that transformed my productivity:

Mastering JavaScript: Functions, Objects, Classes & Prototypes Explained Like Never Before

Mastering JavaScript: Functions, Objects, Classes & Prototypes Explained Like Never Before

If you’re learning JavaScript, you’ve probably heard terms like functions, objects, classes, constructors, inheritance, and prototypes being thrown around. But what do they really mean? And why are they so important in JavaScript? In this blog, we’ll break down these concepts step by step, with clear explanations, examples, comparisons, and diagrams. By the end, you’ll have a solid understanding of how these features work together — and why they are the backbone of modern JavaScript.

Google Tools for College Students to boost Productivity

Google Tools for College Students to boost Productivity

College life can feel like a roller coaster — assignments, exams, group projects, internships, and of course, trying to squeeze in a social life. The good news? You don’t have to do it all alone. Google has built a whole ecosystem of tools that can help students stay productive, organized, and even a little more stress-free. From taking notes to collaborating on projects, Google’s apps are like a digital toolkit every student should know about. Let’s explore how these tools can make your college journey smoother.

Can AI Make Our Food Safer Than Ever?

Can AI Make Our Food Safer Than Ever?

Every year, millions of people around the world get sick from eating contaminated food. The World Health Organization (WHO) estimates that more than 600 million people fall ill annually, and about 4.2 million die from foodborne diseases. That’s a huge number — and the scary part is, much of it comes from something we can’t even see: toxic fungi known as mycotoxins. But now, scientists may have found a way to stop this problem before it even reaches our plates. Thanks to artificial intelligence (AI) and a powerful imaging technology, our food supply could soon become safer than ever.

What is Generative AI?

What is Generative AI?

Artificial Intelligence has gone from beating humans at chess to creating human-like poetry, realistic images, and even functional code. This creative side of AI is called Generative AI — and it’s one of the most exciting areas in modern technology. But to truly understand what Generative AI means, we need to take a quick trip through history, starting with an idea that shaped all of computer science: the Turing Machine.

The Evolution of AI - From Turing to Today

The Evolution of AI - From Turing to Today

Artificial Intelligence (AI) didn’t just appear out of thin air. The chatbot answering your questions today, the recommendation system suggesting your next Netflix binge, and the self-driving cars making headlines — all of these are the result of decades of innovation, setbacks, and breakthroughs. AI’s story is one of human curiosity: a mix of science fiction dreams, brilliant engineering, and a dash of “what if machines could think?” Let’s rewind the clock and see how it all began.

HTML the Easy Way-Unlock the web

HTML the Easy Way-Unlock the web

If you’ve ever wondered how websites are built, here’s the secret: almost every webpage you see starts with HTML. Whether it’s a simple blog post, an online shop, or a social media site – HTML is the foundation.

JUnit 5 and Mockito – From Scratch to Advanced

JUnit 5 and Mockito – From Scratch to Advanced

Learn JUnit 5 & Mockito from scratch to advanced with real-time Spring Boot examples. Covers unit & integration testing, annotations, MockMvc, H2 DB, and best practices.

Modern JavaScript for Developers in 2026

Modern JavaScript for Developers in 2026

Discover the modern JavaScript features developers should know in 2026 and learn how to future-proof your skills for the evolving web landscape. This in-depth guide covers JavaScript trends 2026, emerging frameworks, and best practices to help you stay ahead in web development. Explore the top JavaScript frameworks to watch in 2026, find out what’s new in modern JS features, and see how AI-assisted JavaScript development is shaping the future. Whether you’re updating your JavaScript developer roadmap 2026 or just getting started, this article will help you master the modern JavaScript tools and techniques needed to build fast, scalable, and future-ready applications.

Debouncing in JavaScript

Debouncing in JavaScript

In this article we will learn about the debouncing . We will learn about actual real problem and how to solve this problem using js debouncing.

Maven Tutorial

Maven Tutorial

Maven is a build automation tool primarily used for Java projects. It addresses two main aspects of building software: dependency management and project build lifecycle management.

Share this article ...

💬WhatsApp📘Facebook💼LinkedIn🐦X