AWS

How to Install MySQL on AWS EC2 Linux

MySQL Server can easily be installed in the EC2 instance of AWS running a Linux OS or Ubuntu OS through very basic Linux commands. However, some Linux distributions come with pre-installed MySQL servers, so you can choose that particular distribution when creating the EC2 instance or choose an image with a preconfigured MySQL database setup. But, if you wish to install MySQL manually, then you can simply read the process displayed within this article.

Procedure to Install MySQL on AWS EC2 Linux

To install MySQL server on AWS EC2 virtual machine, connect to your EC2 virtual machine. For that, simply select your virtual machine and click on the “Connect” button:

After that, simply select the “SSH client” tab and copy the command given as an example on this page. Simply paste that command in either the command prompt or PowerShell then change the file path with the file location on your PC.

After the command, you need to hit enter, and you will be connected to your EC2 Linux through the SSH terminal.

Once you are connected to your EC2 instance, it is always a good practice to ensure that your apt packages are all up to date, to do exactly that, run the following command:

sudo apt update

After completing the updates, enter the command for installation.

sudo apt install mysql-server

Simply write the following command and hit “enter”, then it will prompt you to enter “y” if you want to continue with the installation. Simply enter “y” and press enter one more time.

After verification, your MySQL server is installed on your virtual machine.

Once the installation is done, you can start working the MySQL by heading inside its shell, to do that, type:

mysql -uroot -p;

After that, type in the password for the root user, and then you will get the following output on the terminal of your EC2 instance:

This means that you are now inside the MySQL shell, and your installation is successful.

Conclusion

Start by connecting to the SSH of your EC2 that is running a Linux based operating system and then update the apt packages. Once that is done, install MySQL, and once the installation process is done, verify it by heading inside the shell of MySQL. This post has taught you the procedure of installing a MySQL server on AWS EC2 running a Linux based OS.

About the author

Abdul Mannan

I am curious about technology and writing and exploring it is my passion. I am interested in learning new skills and improving my knowledge and I hold a bachelor's degree in computer science.