In this article, I will show you how you can install MySQL server on your Ubuntu machine on AWS, which may help you to get started with your project deployment to AWS. But before that, let me explain what is MySQL.
What is the MySQL database?
MySQL is an open-source relational database management system. Its name is a combination of “My”, the name of co-founder Michael Widenius’s daughter, and “SQL”, the abbreviation for Structured Query Language. Wikipedia
So now we understand that, MySQL is an open-source SQL based database management system. According to this statistics published by statista.com, MySQL is the 2nd most popular database management system in planet Earth. Oracle is not free and also not open-source, so if we consider among the free database management systems, then we can say that MySQL is number 1 in this ranking.
Why you want to install MySQL in Ubuntu ?
As we discuss in previous section that MySQL is the number 1 DBMS among the open-source providers, let’s discuss here, what is Ubuntu and why we want to install MySQL in Ubuntu.
Ubuntu is a Linux distribution based on Debian mostly composed of free and open-source software. Ubuntu is officially released in three editions: Desktop, Server, and Core for the Internet of things devices and robots. All the editions can run on the computer alone, or in a virtual machine. Wikipedia
There are many open-source Linux distributions available and ubuntu is one of the most popular Linux distributions among Desktop and Server Edition. So if you are hosting a blog site or corporate website, chances are there that it is a Ubuntu server and you don’t even know about it. In most cases, this is fine, because someone else is managing your server, but when you want to manage your own server in AWS or other cloud computing platforms, then it’s obvious that you need to know how to setup MySQL over there. Because your website or application may be using MySQL as their Database system and you must install it on your server to run it smoothly.
How to Install MySQL on Ubuntu Machines
So Ubuntu is one of the most popular operating systems in the World and that’s why we need to know how can we install MySQL database server on Ubuntu. At first, you create an EC2 instance in AWS by following my article and then connect to it via Putty or Terminal. I have another article written on how you can connect to your server using Putty here.
Next, I will provide the commands which you can use to install the MySQL server into your Ubuntu EC2 instance. Let me explain the commands one by one so that you know what you doing and if you stuck anywhere then you can search the issue specifically by seeing the error message. Note that anything is written after hash-tag(#) is a comment and it will be ignored by SHELL, but we put these comments for you so that you can understand what is happening and later on debug quicker.
#Setup MySQL server in Ububtu 18.04 in AWS sudo apt-get update
The command written above sudo apt-get update is used to download package information from all configured sources. The sources often defined in /etc/apt/sources.list file and other files located in /etc/apt/sources.list.d/ directory. So when you run the update command, it downloads the package information from the Internet. It is useful to get info on an updated version of packages or their dependencies.
So far, we have updated our packages, next we are going to run the command to install the MySQL server.
#install the mysql server sudo apt-get install mysql-server
There will be some options will be displayed when you run the install command, choose the answer as displayed in the video below to avoid any further issues after installation.
As we have installed the MySQL server on Ubuntu, we need to secure the installation by running the below command. It will also ask you a few questions, which I have answered in the Video below.
#secure your installation sudo mysql_secure_installation utility
After securing the MySQL installation, please run the following command to allow the ubuntu default firewall ufw to run MySQL in the server.
#allow mysql sudo ufw enable sudo ufw allow mysql
If you have came to this state so far, then you did a great job on installing MySQL and securing it in Ubuntu. Next start the server and configure it so that, when Ubuntu reboots, MySQL auto starts. The commands are given below.
#start the mysql server sudo systemctl start mysql #enable mysql on system reboot sudo systemctl enable mysql
Next, I have included the video where I have shown all the steps from my screen.
So in this article, we have seen that MySQL is the number 1 database management system on this planet earth when it comes to open source free alternatives and 2nd in among all RDBMS. WordPress runs on MySQL, so do other popular CMS like Joomla, Drupal, Magento runs on MySQL database. It’s really important to know as a system administrator or DevOps that how you can install MySQL on AWS using Ubuntu OS. I hope this might helped you to start with AWS and MySQL and if you stuck on any issues feel free to contact me via [email protected] or call me @ +8801554306975
3 thoughts on “How to Setup MySQL server in Ubuntu 18.04 in AWS”
Pingback: How to setup Wordpress With Redis - AWS with Atiq
Pingback: How to Install PHP 8 on AWS EC2 instance - AWS with Atiq
Pingback: How to setup WordPress With Redis - Top WordPress Tips