#!/bin/bash

# Update the system
sudo yum update -y

# Download the MySQL Yum Repository configuration package
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

# Install the MySQL Yum Repository
sudo rpm -ivh mysql57-community-release-el7-11.noarch.rpm

# Install MySQL Server
sudo yum install mysql-server -y

# Enable lower_case_table_names in the MySQL configuration
sudo sh -c "echo 'lower_case_table_names = 1' >> /etc/my.cnf"

# Start the MySQL service
sudo systemctl start mysqld

# Secure the MySQL installation
sudo mysql_secure_installation

# Restart the MySQL service
sudo systemctl restart mysqld

# Optional: Enable MySQL to start automatically on boot
sudo systemctl enable mysqld