icon Register for Oracle RAC DBA Demo -29 April at 8 PM IST ENROLL NOW

Mysql Installation step-by-step

Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
  • 30 Apr, 2026
  • 0 Comments
  • 1 Min Read

Mysql Installation step-by-step

MySQL Installation on AWS (Ubuntu) – Step-by-Step Guide

Setting up MySQL on AWS is a must-have skill for database professionals. In this guide, we’ll walk through creating an Ubuntu server on AWS, installing MySQL using the APT repository, and configuring it properly.

Step 1: Create Ubuntu Server on AWS (EC2)

  1. Log in to your Amazon Web Services account
  2. Go to EC2 Dashboard → Click Launch Instance
  3. Configure instance:
    • Name: MySQL-Server
    • OS: Ubuntu Server (20.04 / 22.04)
    • Instance Type: t2.micro (Free Tier)
  4. Create or select a Key Pair (SSH key)
  5. Configure Security Group:
    • Allow SSH (22) → Your IP
    • Allow MySQL (3306) → (Optional, restrict for security)
  6. Click Launch Instance

Step 2: Connect to Ubuntu Server via SSH

Open terminal and run:

chmod 400 your-key.pem
ssh -i your-key.pem ubuntu@your-public-ip

Step 3: Linux Permissions & Sudo Access

  • Switch to root (admin mode):
sudo -i

Linux Permission Basics:

  • Read = 4
  • Write = 2
  • Execute = 1

Example:

chmod 755 filename

Step 4: Update System Packages

apt update && apt upgrade -y

Step 5: Install MySQL using APT Repository

1. Download MySQL APT Repository

wget https://dev.mysql.com/get/mysql-apt-config_0.8.29-1_all.deb

2. Install Repository Package

dpkg -i mysql-apt-config_0.8.29-1_all.deb
  • Select MySQL version (keep default recommended)

3. Update Packages Again

apt update

4. Install MySQL Server

apt install mysql-server -y

Step 6: Verify MySQL Installation

Check package:

dpkg -l | grep mysql-server

Check service status:

systemctl status mysql

Start MySQL (if not running):

systemctl start mysql
systemctl enable mysql

Step 7: Secure MySQL Installation

Run:

mysql_secure_installation
  • Set root password
  • Remove anonymous users → Yes
  • Disable remote root login → Yes
  • Remove test database → Yes

Step 8: MySQL Configuration (my.cnf)

Main config file location:

/etc/mysql/mysql.conf.d/mysqld.cnf

Edit file:

nano /etc/mysql/mysql.conf.d/mysqld.cnf

Important Settings:

[mysqld]
basedir = /usr
datadir = /var/lib/mysql
bind-address = 0.0.0.0   # Allow remote access (use carefully)
port = 3306

Save and restart:

systemctl restart mysql

Step 9: Base Directory & Data Directory

  • Base Directory/usr
  • Data Directory/var/lib/mysql

Check data files:

ls /var/lib/mysql

Step 10: Login to MySQL

mysql -u root -p

Enter your password.

Step 11: Basic Database Operations

Create Database

CREATE DATABASE testdb;

Show Databases

SHOW DATABASES;

Use Database

USE testdb;

Create Table

CREATE TABLE users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(100),
  email VARCHAR(100)
);

Step 12: Create MySQL User

CREATE USER 'admin'@'%' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;

 

lets talk - learnomate helpdesk

Book a Free Demo