First you need to connect to your Amazon EC2 instance with SSH, you can do that by using PuTTy on windows and Terminal on Linux or Mac. Once you’re connected to EC2 server, issue the following commands to install MySQL.
yum install mysql mysql-server mysql-libs service mysqld start chkconfig --levels 235 mysqld on
If you want to make your MySQL secure, then issue the following command. Answer each question either Y or N for Yes or No. Securing MySQL just mean that you provide a password for root user, delete the guest user and a few more simple things.
Thats it! MySQL is installed. Now, lets login to MySQL and play around.
First lets login with root user having no password
mysql -h localhost -u root -p
Create a dummy database my_first_db
create database my_first_db;
If command runs successfully, you will see a message similar to this
Query OK, 1 row affected (0.00 sec)
Lets confirm if our database has been created. Issue the following command
and you may see something similar to this
| Database |
| information_schema |
| my_first_db |
| mysql |
| performance_schema |
| test |
5 rows in set (0.00 sec)
Lets create a small table in my_first_db. Following is the table create statement
CREATE TABLE my_table ( firstname VARCHAR(20), lastname VARCHAR(35), email VARCHAR(35) );
Lets confirm if our table is created with the following command
You may see something like this
| Field | Type | Null | Key | Default | Extra |
| firstname | varchar(20) | YES | | NULL | |
| lastname | varchar(35) | YES | | NULL | |
| email | varchar(35) | YES | | NULL | |
3 rows in set (0.00 sec)
That’s it. You have installed and tested MySQL server on Amazon EC2.