Voiced by Amazon Polly |
Overview of Hosted and Traditional Database
Traditional databases provide for the management of underlying business resources and infrastructure on corporate premises. Fortunately, cloud databases have transformed that industry by making the same resources available on a pay-as-you-go basis.
Provisioning firm infrastructure and resources in data centers to administer and on-site a database is costly and time-consuming. Traditional databases need extensive preparation in terms of purchase orders for both hardware and database software.
Cloud databases have a crucial advantage over traditional databases in that they allow organizations with critical data-resource requirements to grow on demand without worrying about availability or security—the cloud provides multiple database replication across several geographical locations.
Customized Cloud Solutions to Drive your Business Success
- Cloud Migration
- Devops
- AIML & IoT
Real-time Scenario Example
Let us suppose that you want to use a database in your application, but you don’t have any data center to host your database, so you have chosen the cloud to host the database. Instead of a managed database, you have opted for a custom installation of a database in the server
Here, I have used the AWS EC2 server to host the database. The database engine is MySQL 8.0.29
Prerequisites
AWS Account
- EC2 Instance
- User with privileges to create an instance
Steps to install MySQL in AWS EC2
Step 1 – Launch an EC2 Server with Ubuntu 18.04
Step 2 – Check the security group of EC2 Server, which has MySQL/Aurora Port open only from specified IP Address and SSH port from your IP Address
Step 3 – SSH inside the machine
Step 4 – SSH Inside the machine and Update and install mysql-server
1 |
sudo apt update && sudo apt install mysql-server |
Step 5 – Go inside your MySQL
1 |
sudo mysql |
Step 6 – Alter root user credentials for the database and flush all the privileges
1 2 |
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; FLUSH PRIVILEGES; |
Step 7 – Check whether the password is applied for the root user or not
1 |
SELECT user,authentication_string,plugin,host FROM mysql.user; |
1 |
<img decoding="async" class="alignnone wp-image-15228 size-full" src="https://content.cloudthat.com/resources/wp-content/uploads/2022/10/Step7.png" alt="Step7" width="626" height="173" srcset="https://content.cloudthat.com/resources/wp-content/uploads/2022/10/Step7.png 626w, https://content.cloudthat.com/resources/wp-content/uploads/2022/10/Step7-300x83.png 300w" sizes="(max-width: 626px) 100vw, 626px" /> |
Steps to Connect to EC2 database remotely
Step 1 – Create a new remote user in MySQL, create a new user, and give permission as required. Here I’m giving all privileges to test
1 2 |
CREATE USER 'test’'@'%’' IDENTIFIED BY 'Password@1234'; GRANT ALL PRIVILEGES ON *.* to test@'%' IDENTIFIED BY 'Password@1234' WITH GRANT OPTION; |
Note: Don’t use any reserved keyword to create a remote user like (root, Admin, Admin)
Step 2 – Change the data-bind address to the IP where you want to access the database
- Set the MySQL server to listen to all IP addresses on the system if you wish to connect to it via a public network. To do so, modify the MySQL configuration file and add or update the bind-address option’s value. You can configure a single IP address as well as IP ranges. The MySQL server accepts connections on all host IPv4 interfaces if the address is 0.0.0.0. If your machine is set for IPv6, use: instead of 0.0.0.0
- Depending on the distribution, the location of the MySQL configuration file varies. The file is placed at /etc/mysql/mysql.conf.d/mysqld.cnf in Ubuntu and Debian, and at/etc/my.cnf in Red Hat-based distributions such as CentOS.
Step 3 – Restart MySQL Server
1 2 |
sudo systemctl restart mysql.service sudo systemctl status mysql.service |
Step 4 – Check Connection
Check connection of database using PHP
Conclusion
If you need an automated solution, go for the managed database; for more control and flexibility, go for manual database hosting.
For some cases like automated backups, security, and updating versions, this will be taken care of by managed database. If you want to have control of the OS, manage your database by looking after clustering and replication, then go for the manually hosted database.
The choice ultimately comes down to whether you prefer manual or automated operations, how much time it will cost, and your management abilities.
Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.
- Cloud Training
- Customized Training
- Experiential Learning
About CloudThat
CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.
CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 850k+ professionals in 600+ cloud certifications and completed 500+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training Partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, AWS GenAI Competency Partner, Amazon QuickSight Service Delivery Partner, Amazon EKS Service Delivery Partner, AWS Microsoft Workload Partners, Amazon EC2 Service Delivery Partner, Amazon ECS Service Delivery Partner, AWS Glue Service Delivery Partner, Amazon Redshift Service Delivery Partner, AWS Control Tower Service Delivery Partner, AWS WAF Service Delivery Partner, Amazon CloudFront Service Delivery Partner, Amazon OpenSearch Service Delivery Partner, AWS DMS Service Delivery Partner, AWS Systems Manager Service Delivery Partner, Amazon RDS Service Delivery Partner, AWS CloudFormation Service Delivery Partner, AWS Config, Amazon EMR and many more.
FAQs
1. Should the subnet associated with the server be public or private?
ANS: – The subnet should be public. Otherwise, we would not be able to connect the database to the application code
2. Can we access the hosted database on private IP?
ANS: – Yes, if our hosted database and Application code lie in the same VPC
3. Are manual hosted databases best as compared to the database which Cloud Providers offer?
ANS: – If you want to have complete control over the database users and privileges including patching and updating, then you can opt for hosting the database manually otherwise hosted DB which is offered by cloud providers are good option to pick up
4. Can we secure the manually hosted database?
ANS: – Yes, you can secure the manual hosted database from three different places-
(i) From AWS Network Access Control List (NACL)
(ii)From EC2 Security Group
(iii)From MySQL config file bind-address
(iv)By giving required access to users created in the database
WRITTEN BY Rishi Raj
Comments