Creating a Server and Client Web Architecture Using Mysql
The client-server architecture refers to a system that hosts, delivers, and manages most of the resources and services that the client requests. In this model, all requests and services are delivered over a network, and it is also referred to as the networking computing model or client server network.
Client-server architecture, alternatively called a client-server model, is a network application that breaks down tasks and workloads between clients and servers that reside on the same system or are linked by a computer network.
Client-server architecture typically features multiple users’ workstations, PCs, or other devices, connected to a central server via an Internet connection or other network. The client sends a request for data, and the server accepts and accommodates the request, sending the data packets back to the user who needs them.
In this project, we are going to demonstrate the server and client connection using two AWS ec2 instances, one as server, the other as client and connecting them over the public IP address rather than ssh
Create two linux based ec2 instances, name one as Mysql-server
and the other as Mysql-client
. Save their keypairs as .pem and connect to them on your terminal
On the mysql-server, install mysql server: Run
sudo apt update
sudo apt upgrade
sudo apt install mysql-server
start mysql. Run
sudo mysql
Create a user and set password
CREATE USER 'username'@'host' IDENTIFIED WITH authentication_plugin BY 'password';
Create database. Run:
CREATE DATABASE <DBname>
In the image above, we created a database named conn_Test
Grant privileges to the created user on the database. Run
GRANT ALL PRIVILEGES ON *.* TO 'username'@'host' WITH GRANT OPTION;
Still on the mysql_server, we need to open the port for our server to be accessible
Open mysql_server instance and open port 3306
We need to edit our server configuration file to allow access from remote hosts
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
. Edit the bind-address part having 127.0.0.1 to 0.0.0.0
On the mysql_client instance, We will acess the mysql server through the ip address next
Run
sudo mysql -u username -h <public-ip-address> -p
When promted for password, enter the password for the mysql user.
This page shows the client connected successfully to mysql_server.
To confirm this, let us check the database created on mysql server. Run:
mysql> show databases
The page above shows the database we created on msql_server. This confirms a successful connection from the mysql client to mysql server
DONE