Skip to content

bienary/Client-Server-Architecture-with-MySQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 

Repository files navigation

๐Ÿ–ง Client-Server-Architecture-with-MySQL

๐ŸŒซ DevOps/Cloud Engineering ~ Client-Server Architecture with MySQL

Understanding Client-Server Architecture

  • Client-Server refers to an architecture in which two or more computers are connected together over a network to send and receive requests between one another.

  • In their communication, each machine has its own role:

The machine sending requests is usually referred to as the "Client"

The machine responding (serving) is called the "Server"

Our Web Server has a role of a Client that connects and reads/writes to/from a Database (DB) Server (MySQL, MongoDB, Oracle, SQL Server or any other), and the communication between them happens over a Local Network (it can also be Internet connection, but it is a common practice to place Web Server and DB Server close to each other in local network).


๐ŸŽฏStep-by-step guide on how to implement MySQL Client-Server architecture on AWS EC2 Linux instances

1. ๐Ÿ’ผ Setup EC2 Instances

  • Create two EC2 instances running Ubuntu Linux.

  • Name one mysql-server and the other mysql-client.

Screenshot From 2025-09-25 22-46-11

๐ŸŒ Allow inbound traffic on port 3306 in mysql-server security group

  • Go to AWS Console > EC2 > Security Groups.

  • Select the security group attached to mysql-server.

  • Add a new Inbound rule: Select Custom TCP > Port 3306 > Enter the private IP of MySQL-Client instance only

image

2. ๐Ÿ› ๏ธ On mysql-server instance: Install MySQL Server

  • SSH into the Server instance.
ssh -i <Your-private-key.pem> ubuntu@<EC2-Public-IP-address>
  • Update and Upgrade system packages:
sudo apt update && sudo apt upgrade
  • install MySQL Server
sudo apt install mysql-server -y
Screenshot From 2025-09-25 23-16-07
  • Check MySQL service status
sudo systemctl status mysql
Screenshot From 2025-09-25 23-18-28

3. ๐Ÿ›๏ธ On mysql-client instance: Install MySQL Client

  • SSH into the Client instance.
ssh -i <Your-private-key.pem> ubuntu@<EC2-Public-IP-address>
  • Update and Upgrade system packages:
sudo apt update && sudo apt upgrade
  • install MySQL Server
sudo apt install mysql-client -y
image

4. ๐Ÿ”จ Configure MySQL server to accept remote connections

sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
image
  • Restart MySQL Server to apply changes
sudo systemctl restart mysql

5. ๐Ÿ“Œ Create MySQL user with remote access permissions on mysql-server

  • Login to MySQL Server
sudo mysql
  • Create a user that can connect remotely
CREATE USER 'remoteuser'@'client_private_ip' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON *.* TO 'remoteuser'@'client_private_ip' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
image
  • Check that you have successfully connected to a remote MySQL server and can perform SQL queries:
show databases;
Screenshot From 2025-09-26 00-55-36 - Add some data:
CREATE DATABASE binary_db;
USE binary_db;
INSERT INTO employees (name, position, salary) VALUES 
('Oladapo', 'DevOps Engineer', 200000.00),
('Dolapo', 'IT Manager', 350000.00),
('Funmilayo', 'Intern', 75000.00);
image

โœ… Conclusion

  • We have successfully implemented a basic Client-Server architecture using MySQL. By setting up two Linux-based EC2 instances, configuring MySQL for remote access, securing user permissions, and connecting via the MySQL client, weโ€™ve built a fully functional environment for remote database operations.

About

DevOps/Cloud Engineering ~ Client-Server Architecture with MySQL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published