SlideShare a Scribd company logo
1 of 20
Download to read offline
How to Setup
and Connect
MySQL to
EC2 Instance
from Ubuntu
www.bacancytechnology.com
MYSQL is a famous open-source relational
database management system that provides
scalable and easy-to-use function sets. It
uses a relational DB and Structured Query
Language (SQL) for managing its data.
This tutorial describes a basic MySQL
installation and setup; later we will connect
MySQL to EC2 instance from Ubuntu. Once
done with the basics, we will create a user
for our database.
What is AWS
EC2?
AWS EC2 – AWS Elastic Compute Cloud is
one of the most famous Amazon services
that provides the ability of running the app
on the public cloud. It offers safe, reliable,
and resizable cloud capacity with minimum
obstacles.
I assume that you are quite familiar with
Amazon EC2 and MySQL to proceed with
MySQL Setup in EC2 Ubuntu Instance.
Prerequisites
Create EC2 Ubuntu Instance in AWS
Account
Connect EC2 Instance using SSH or
Putty
To get started with the tutorial for setting
up MySQL in EC2 Ubuntu Instance, please
make sure of the following prerequisites-
Now, let’s move towards how to set up and
connect MySQL to EC2 Instance Ubuntu.
6 Steps to
Setup and
Connect
MySQL to EC2
Instance from
Ubuntu
Step 1: Update System
Packages and Install
MySQL
Run install update for your server system
packages
sudo apt update
Now, install MySQL using the below
command to install the latest MySQL.
sudo apt-get install mysql-server -y
After successful installation of mysql-
server, we can check the MySQL version by
using this command-
mysql --version
Step 2: Configure MySQL
Installation
To configure the installation of MySQL, run
the security script with sudo to run as the
root user- the super privileged user.
Run the below command-
sudo mysql_secure_installation
When we install MySQL for the first time, we
will be prompted to create a new password.
If you are getting an error while setting up
the password, check the temporary
password in the log file.
Use the below command to get a temporary
password.
cat /var/log/mysqld.log
We can find something like this:
Step 3: Login into MySQL
and Create a User
Use the below command to login into
MySQL:
sudo mysql
The command will log in to MySQL using
the root user. Once you are logged in, create
a user in the MySQL database using these
commands:
use mysql;
CREATE USER 'username'@'host'
IDENTIFIED WITH
mysql_native_password BY 'password';
Step 4: Grant Access
Privileges to User
Now, to grant access privileges to this
newly created user, use this command:
GRANT ALL PRIVILEGES ON *.* TO
'username'@'host';
Once this is done, run this command,
FLUSH PRIVILEGES;
Step 5: Connect User with
MySQL
Now you can use this user to connect with
MySQL like this:
mysql -u user -p
Once prompted for a password, provide the
password, and you will be connected.
Trick: If you want to store passwords for
that user, so prompting will not annoy us,
do these things.
Create .my.cnf file inside /home/Ubuntu
path
Write this command:
sudo nano .my.cnf
Write these lines in that file and save.
[mysql]
user=username
password=password
Now, whenever you want to connect, you
can use this .my.cnf file like this, and no
need to provide a password.
mysql --defaults-
file=/home/ubuntu/.my.cnf -u username
This file is generally needed when running
the CI/CD pipeline and connecting to
another server’s MySQL server.
Step 6: Restart MySQL
Service
To affect these changes, restart the MySQL
service by following commands:
to check the status of MySQL service:
systemctl status mysql.service
Now, if it is in “Running” mode, then restart
it using the below command:
sudo service mysql restart
This will restart the service and will reflect
our changes.
Now, your MySQL has been set up in your
Ubuntu Ec2 Instance.
Quick Read:
Cloud Cost Optimization: An Essential
Guide to AWS Cloud Migration
Conclusion
So, this was about how we can set up
MySQL in EC2 Ubuntu Instance. If you have
followed all the steps as discussed above,
then MySQL setup is successfully done in
EC2 Ubuntu Instance. Moreover, we
covered creating a new database and adding
a user to it. For more such tutorials, you can
visit the Cloud Tutorials page to explore
more about Cloud and DevOps services.
Are you looking for a certified architect for
managing AWS services? Then, without
wasting your time, connect us to hire AWS
experts. Bacancy has proficient and
qualified experts with AWS certifications
who have competence in providing
optimum solutions.
Thank You
www.bacancytechnology.com

More Related Content

What's hot

Cluster Computing for $0.27/hr using Amazon EC2 and IPython Notebook
Cluster Computing for $0.27/hr using Amazon EC2 and IPython NotebookCluster Computing for $0.27/hr using Amazon EC2 and IPython Notebook
Cluster Computing for $0.27/hr using Amazon EC2 and IPython NotebookRandy Zwitch
 
Multiple instance on windows
Multiple instance on windowsMultiple instance on windows
Multiple instance on windowsVasudeva Rao
 
Cookies in Angular | Install CookiesService
Cookies in Angular | Install CookiesServiceCookies in Angular | Install CookiesService
Cookies in Angular | Install CookiesServicePradeep Kumar
 
ember-socket-guru - common api for websockets providers
ember-socket-guru - common api for websockets providersember-socket-guru - common api for websockets providers
ember-socket-guru - common api for websockets providersKuba Niechciał
 
Your own minecraft server on a linode vps
Your own minecraft server on a linode vpsYour own minecraft server on a linode vps
Your own minecraft server on a linode vpsCleo Morisson
 
Visual Programming Framework for Unity - UniFlow のご紹介
Visual Programming Framework for Unity - UniFlow のご紹介Visual Programming Framework for Unity - UniFlow のご紹介
Visual Programming Framework for Unity - UniFlow のご紹介Mori Tetsuya
 
SULTHAN's PHP, MySQL & wordpress
SULTHAN's PHP, MySQL & wordpressSULTHAN's PHP, MySQL & wordpress
SULTHAN's PHP, MySQL & wordpressSULTHAN BASHA
 
Mule security - ldap for spring security
Mule  security - ldap for spring securityMule  security - ldap for spring security
Mule security - ldap for spring securityD.Rajesh Kumar
 
Module 1 introduction to aws demo 4
Module 1 introduction to aws demo 4Module 1 introduction to aws demo 4
Module 1 introduction to aws demo 4Ganesh Bhosale
 
Database systems administration traning 0
Database systems administration traning 0Database systems administration traning 0
Database systems administration traning 0Shahid Riaz
 
Terraform bootstrap code_execute
Terraform bootstrap code_executeTerraform bootstrap code_execute
Terraform bootstrap code_executerknaik76
 
Standing on the shoulders of Giants
Standing on the shoulders of Giants Standing on the shoulders of Giants
Standing on the shoulders of Giants sshreyas
 
Elastic Beanstalk 이용한 Django 배포
Elastic Beanstalk 이용한 Django 배포 Elastic Beanstalk 이용한 Django 배포
Elastic Beanstalk 이용한 Django 배포 Kim SeokYoung
 
Dspace for windows
Dspace for windowsDspace for windows
Dspace for windowsRavi Bankar
 

What's hot (20)

Cluster Computing for $0.27/hr using Amazon EC2 and IPython Notebook
Cluster Computing for $0.27/hr using Amazon EC2 and IPython NotebookCluster Computing for $0.27/hr using Amazon EC2 and IPython Notebook
Cluster Computing for $0.27/hr using Amazon EC2 and IPython Notebook
 
Multiple instance on windows
Multiple instance on windowsMultiple instance on windows
Multiple instance on windows
 
Cookies in Angular | Install CookiesService
Cookies in Angular | Install CookiesServiceCookies in Angular | Install CookiesService
Cookies in Angular | Install CookiesService
 
Virtual server on aws
Virtual server on awsVirtual server on aws
Virtual server on aws
 
Intalacion de owncloud
Intalacion de owncloudIntalacion de owncloud
Intalacion de owncloud
 
ember-socket-guru - common api for websockets providers
ember-socket-guru - common api for websockets providersember-socket-guru - common api for websockets providers
ember-socket-guru - common api for websockets providers
 
Your own minecraft server on a linode vps
Your own minecraft server on a linode vpsYour own minecraft server on a linode vps
Your own minecraft server on a linode vps
 
Play Framework in EC2
Play Framework in EC2Play Framework in EC2
Play Framework in EC2
 
Visual Programming Framework for Unity - UniFlow のご紹介
Visual Programming Framework for Unity - UniFlow のご紹介Visual Programming Framework for Unity - UniFlow のご紹介
Visual Programming Framework for Unity - UniFlow のご紹介
 
Core data optimization
Core data optimizationCore data optimization
Core data optimization
 
SULTHAN's PHP, MySQL & wordpress
SULTHAN's PHP, MySQL & wordpressSULTHAN's PHP, MySQL & wordpress
SULTHAN's PHP, MySQL & wordpress
 
Mule security - ldap for spring security
Mule  security - ldap for spring securityMule  security - ldap for spring security
Mule security - ldap for spring security
 
VPNaaS neutron
VPNaaS neutronVPNaaS neutron
VPNaaS neutron
 
Module 1 introduction to aws demo 4
Module 1 introduction to aws demo 4Module 1 introduction to aws demo 4
Module 1 introduction to aws demo 4
 
Database systems administration traning 0
Database systems administration traning 0Database systems administration traning 0
Database systems administration traning 0
 
Terraform bootstrap code_execute
Terraform bootstrap code_executeTerraform bootstrap code_execute
Terraform bootstrap code_execute
 
Standing on the shoulders of Giants
Standing on the shoulders of Giants Standing on the shoulders of Giants
Standing on the shoulders of Giants
 
Solaris mysql sop
Solaris mysql sopSolaris mysql sop
Solaris mysql sop
 
Elastic Beanstalk 이용한 Django 배포
Elastic Beanstalk 이용한 Django 배포 Elastic Beanstalk 이용한 Django 배포
Elastic Beanstalk 이용한 Django 배포
 
Dspace for windows
Dspace for windowsDspace for windows
Dspace for windows
 

Similar to Setup and Connect MySQL Database to EC2 Instance on Ubuntu

Setting up MySQL Replication Cluster in Kubernetes
Setting up MySQL Replication Cluster in KubernetesSetting up MySQL Replication Cluster in Kubernetes
Setting up MySQL Replication Cluster in KubernetesElizabeth Yu, MBA
 
Getting started with my sql
Getting started with my sqlGetting started with my sql
Getting started with my sqlWeb Sky
 
Kubernetes - Using Persistent Disks with WordPress and MySQL
Kubernetes - Using Persistent Disks with WordPress and MySQLKubernetes - Using Persistent Disks with WordPress and MySQL
Kubernetes - Using Persistent Disks with WordPress and MySQLpratik rathod
 
Mater,slave on mysql
Mater,slave on mysqlMater,slave on mysql
Mater,slave on mysqlVasudeva Rao
 
Kubernetes Hands-On Guide
Kubernetes Hands-On GuideKubernetes Hands-On Guide
Kubernetes Hands-On GuideStratoscale
 
Mysql connection
Mysql connectionMysql connection
Mysql connectionbeben benzy
 
Connect sql-using-perl-from-linux
Connect sql-using-perl-from-linuxConnect sql-using-perl-from-linux
Connect sql-using-perl-from-linuxVenkat Raman
 
Setting up JupyterHub on AWS
Setting up JupyterHub on AWSSetting up JupyterHub on AWS
Setting up JupyterHub on AWSMel Denisse
 
Scaling on EC2 in a fast-paced environment (LISA'11 - Full Paper)
Scaling on EC2 in a fast-paced environment (LISA'11 - Full Paper)Scaling on EC2 in a fast-paced environment (LISA'11 - Full Paper)
Scaling on EC2 in a fast-paced environment (LISA'11 - Full Paper)Nicolas Brousse
 
How to install and configure lamp (linux,apache mysql mariadb,php) with jooml...
How to install and configure lamp (linux,apache mysql mariadb,php) with jooml...How to install and configure lamp (linux,apache mysql mariadb,php) with jooml...
How to install and configure lamp (linux,apache mysql mariadb,php) with jooml...CloudMinister Technologies Pvt. Ltd
 
Setting up a kubernetes cluster on ubuntu 18.04- loves cloud
Setting up a kubernetes cluster on ubuntu 18.04- loves cloudSetting up a kubernetes cluster on ubuntu 18.04- loves cloud
Setting up a kubernetes cluster on ubuntu 18.04- loves cloudLoves Cloud
 
Architecting cloud
Architecting cloudArchitecting cloud
Architecting cloudTahsin Hasan
 
Ansible & CloudStack - Configuration Management
Ansible & CloudStack - Configuration ManagementAnsible & CloudStack - Configuration Management
Ansible & CloudStack - Configuration ManagementShapeBlue
 

Similar to Setup and Connect MySQL Database to EC2 Instance on Ubuntu (20)

Mysql ppt
Mysql pptMysql ppt
Mysql ppt
 
Setting up MySQL Replication Cluster in Kubernetes
Setting up MySQL Replication Cluster in KubernetesSetting up MySQL Replication Cluster in Kubernetes
Setting up MySQL Replication Cluster in Kubernetes
 
Getting started with my sql
Getting started with my sqlGetting started with my sql
Getting started with my sql
 
Kubernetes - Using Persistent Disks with WordPress and MySQL
Kubernetes - Using Persistent Disks with WordPress and MySQLKubernetes - Using Persistent Disks with WordPress and MySQL
Kubernetes - Using Persistent Disks with WordPress and MySQL
 
Node.js with MySQL.pdf
Node.js with MySQL.pdfNode.js with MySQL.pdf
Node.js with MySQL.pdf
 
Mater,slave on mysql
Mater,slave on mysqlMater,slave on mysql
Mater,slave on mysql
 
Kubernetes Hands-On Guide
Kubernetes Hands-On GuideKubernetes Hands-On Guide
Kubernetes Hands-On Guide
 
Mysql tutorial 5257
Mysql tutorial 5257Mysql tutorial 5257
Mysql tutorial 5257
 
Mysql connection
Mysql connectionMysql connection
Mysql connection
 
Python my sql database connection
Python my sql   database connectionPython my sql   database connection
Python my sql database connection
 
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
 
Connect sql-using-perl-from-linux
Connect sql-using-perl-from-linuxConnect sql-using-perl-from-linux
Connect sql-using-perl-from-linux
 
Setting up JupyterHub on AWS
Setting up JupyterHub on AWSSetting up JupyterHub on AWS
Setting up JupyterHub on AWS
 
Scaling on EC2 in a fast-paced environment (LISA'11 - Full Paper)
Scaling on EC2 in a fast-paced environment (LISA'11 - Full Paper)Scaling on EC2 in a fast-paced environment (LISA'11 - Full Paper)
Scaling on EC2 in a fast-paced environment (LISA'11 - Full Paper)
 
How to install and configure lamp (linux,apache mysql mariadb,php) with jooml...
How to install and configure lamp (linux,apache mysql mariadb,php) with jooml...How to install and configure lamp (linux,apache mysql mariadb,php) with jooml...
How to install and configure lamp (linux,apache mysql mariadb,php) with jooml...
 
Setting up a kubernetes cluster on ubuntu 18.04- loves cloud
Setting up a kubernetes cluster on ubuntu 18.04- loves cloudSetting up a kubernetes cluster on ubuntu 18.04- loves cloud
Setting up a kubernetes cluster on ubuntu 18.04- loves cloud
 
Architecting cloud
Architecting cloudArchitecting cloud
Architecting cloud
 
Ansible & CloudStack - Configuration Management
Ansible & CloudStack - Configuration ManagementAnsible & CloudStack - Configuration Management
Ansible & CloudStack - Configuration Management
 
instaling
instalinginstaling
instaling
 
instaling
instalinginstaling
instaling
 

More from Katy Slemon

React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdfReact Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdfKaty Slemon
 
Data Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdfData Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdfKaty Slemon
 
How Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdfHow Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdfKaty Slemon
 
What’s New in Flutter 3.pdf
What’s New in Flutter 3.pdfWhat’s New in Flutter 3.pdf
What’s New in Flutter 3.pdfKaty Slemon
 
Why Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdfWhy Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdfKaty Slemon
 
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdfHow Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdfKaty Slemon
 
How to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdfHow to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdfKaty Slemon
 
How to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdfHow to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdfKaty Slemon
 
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdfSure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdfKaty Slemon
 
How to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdfHow to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdfKaty Slemon
 
IoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdfIoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdfKaty Slemon
 
Understanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfUnderstanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfKaty Slemon
 
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdfThe Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdfKaty Slemon
 
New Features in iOS 15 and Swift 5.5.pdf
New Features in iOS 15 and Swift 5.5.pdfNew Features in iOS 15 and Swift 5.5.pdf
New Features in iOS 15 and Swift 5.5.pdfKaty Slemon
 
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdfHow to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdfKaty Slemon
 
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdfChoose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdfKaty Slemon
 
Flutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdfFlutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdfKaty Slemon
 
Angular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdfAngular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdfKaty Slemon
 
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdfHow to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdfKaty Slemon
 
Ruby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdfRuby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdfKaty Slemon
 

More from Katy Slemon (20)

React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdfReact Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
 
Data Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdfData Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdf
 
How Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdfHow Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdf
 
What’s New in Flutter 3.pdf
What’s New in Flutter 3.pdfWhat’s New in Flutter 3.pdf
What’s New in Flutter 3.pdf
 
Why Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdfWhy Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdf
 
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdfHow Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
 
How to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdfHow to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdf
 
How to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdfHow to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdf
 
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdfSure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
 
How to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdfHow to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdf
 
IoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdfIoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdf
 
Understanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfUnderstanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdf
 
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdfThe Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
 
New Features in iOS 15 and Swift 5.5.pdf
New Features in iOS 15 and Swift 5.5.pdfNew Features in iOS 15 and Swift 5.5.pdf
New Features in iOS 15 and Swift 5.5.pdf
 
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdfHow to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
 
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdfChoose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
 
Flutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdfFlutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdf
 
Angular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdfAngular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdf
 
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdfHow to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
 
Ruby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdfRuby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdf
 

Recently uploaded

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 

Recently uploaded (20)

Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 

Setup and Connect MySQL Database to EC2 Instance on Ubuntu

  • 1. How to Setup and Connect MySQL to EC2 Instance from Ubuntu www.bacancytechnology.com
  • 2. MYSQL is a famous open-source relational database management system that provides scalable and easy-to-use function sets. It uses a relational DB and Structured Query Language (SQL) for managing its data. This tutorial describes a basic MySQL installation and setup; later we will connect MySQL to EC2 instance from Ubuntu. Once done with the basics, we will create a user for our database.
  • 4. AWS EC2 – AWS Elastic Compute Cloud is one of the most famous Amazon services that provides the ability of running the app on the public cloud. It offers safe, reliable, and resizable cloud capacity with minimum obstacles. I assume that you are quite familiar with Amazon EC2 and MySQL to proceed with MySQL Setup in EC2 Ubuntu Instance.
  • 6. Create EC2 Ubuntu Instance in AWS Account Connect EC2 Instance using SSH or Putty To get started with the tutorial for setting up MySQL in EC2 Ubuntu Instance, please make sure of the following prerequisites- Now, let’s move towards how to set up and connect MySQL to EC2 Instance Ubuntu.
  • 7. 6 Steps to Setup and Connect MySQL to EC2 Instance from Ubuntu
  • 8. Step 1: Update System Packages and Install MySQL Run install update for your server system packages sudo apt update Now, install MySQL using the below command to install the latest MySQL. sudo apt-get install mysql-server -y After successful installation of mysql- server, we can check the MySQL version by using this command- mysql --version
  • 9. Step 2: Configure MySQL Installation To configure the installation of MySQL, run the security script with sudo to run as the root user- the super privileged user. Run the below command- sudo mysql_secure_installation
  • 10. When we install MySQL for the first time, we will be prompted to create a new password. If you are getting an error while setting up the password, check the temporary password in the log file. Use the below command to get a temporary password.
  • 11. cat /var/log/mysqld.log We can find something like this:
  • 12. Step 3: Login into MySQL and Create a User Use the below command to login into MySQL: sudo mysql The command will log in to MySQL using the root user. Once you are logged in, create a user in the MySQL database using these commands: use mysql; CREATE USER 'username'@'host' IDENTIFIED WITH mysql_native_password BY 'password';
  • 13. Step 4: Grant Access Privileges to User Now, to grant access privileges to this newly created user, use this command: GRANT ALL PRIVILEGES ON *.* TO 'username'@'host'; Once this is done, run this command, FLUSH PRIVILEGES;
  • 14. Step 5: Connect User with MySQL Now you can use this user to connect with MySQL like this: mysql -u user -p Once prompted for a password, provide the password, and you will be connected. Trick: If you want to store passwords for that user, so prompting will not annoy us, do these things. Create .my.cnf file inside /home/Ubuntu path Write this command: sudo nano .my.cnf
  • 15. Write these lines in that file and save. [mysql] user=username password=password Now, whenever you want to connect, you can use this .my.cnf file like this, and no need to provide a password. mysql --defaults- file=/home/ubuntu/.my.cnf -u username This file is generally needed when running the CI/CD pipeline and connecting to another server’s MySQL server.
  • 16. Step 6: Restart MySQL Service To affect these changes, restart the MySQL service by following commands: to check the status of MySQL service: systemctl status mysql.service Now, if it is in “Running” mode, then restart it using the below command: sudo service mysql restart
  • 17. This will restart the service and will reflect our changes. Now, your MySQL has been set up in your Ubuntu Ec2 Instance. Quick Read: Cloud Cost Optimization: An Essential Guide to AWS Cloud Migration
  • 19. So, this was about how we can set up MySQL in EC2 Ubuntu Instance. If you have followed all the steps as discussed above, then MySQL setup is successfully done in EC2 Ubuntu Instance. Moreover, we covered creating a new database and adding a user to it. For more such tutorials, you can visit the Cloud Tutorials page to explore more about Cloud and DevOps services. Are you looking for a certified architect for managing AWS services? Then, without wasting your time, connect us to hire AWS experts. Bacancy has proficient and qualified experts with AWS certifications who have competence in providing optimum solutions.