{"id":7145,"date":"2017-11-28T08:42:52","date_gmt":"2017-11-28T00:42:52","guid":{"rendered":"http:\/\/rmohan.com\/?p=7145"},"modified":"2017-11-28T08:42:52","modified_gmt":"2017-11-28T00:42:52","slug":"setting-up-mysql-server-on-aws-ec2-instance","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=7145","title":{"rendered":"Setting up MySQL server on aws EC2\u00a0instance"},"content":{"rendered":"<div id=\"page\" class=\"hfeed\">\n<div id=\"main\">\n<div id=\"primary\">\n<div id=\"content\" role=\"main\">\n<article id=\"post-144\" class=\"post-144 post type-post status-publish format-standard hentry category-aws tag-amazon tag-aws tag-database tag-ec2 tag-instance tag-mysql tag-mysqld tag-server\">\n<div class=\"entry-content\">\n<p>Launch an EC2 instance of type Amazon Linux AMI from your aws console.<\/p>\n<p>SSH into your ec2 instance<br \/>\n<code>ssh -i  ec2-user@my_ec2_ip_address<\/code><\/p>\n<p>Update the instance<br \/>\n<code>sudo yum update -y<\/code><\/p>\n<p>Install the mysqld server<br \/>\n<code>sudo yum install -y mysql55-server<\/code><\/p>\n<p>start the mysqld instance<br \/>\n<code>sudo service mysqld start<\/code><\/p>\n<p>the following command ensure launches mysqld on server restart<br \/>\n<code>sudo chkconfig mysqld on<\/code><\/p>\n<p>run the following command to set password for root user and delete test databases.<br \/>\n<code>sudo mysql_secure_installation<\/code><\/p>\n<p>make a note of the root password ????<\/p>\n<p>Let\u2019s try to create a user and database. This way we can control the database access levels.<br \/>\n<code>mysql -uroot -pmy_root_password<\/code><\/p>\n<p>I\u2019m going to create a <em>db_demo<\/em> with <em>demo_user<\/em> having password <em>demo123<\/em>.<br \/>\n<code>CREATE DATABASE db_demo;<br \/>\nUSE db_demo;<br \/>\nCREATE USER 'demo_user'@'localhost' IDENTIFIED BY 'demo123';<br \/>\nGRANT ALL PRIVILEGES ON *.* TO 'demo_user'@'localhost' WITH GRANT OPTION;<br \/>\nCREATE USER 'demo_user'@'%' IDENTIFIED BY 'demo123';<br \/>\nGRANT ALL PRIVILEGES ON *.* TO 'demo_user'@'%' WITH GRANT OPTION;<br \/>\nFLUSH PRIVILEGES;<br \/>\n<\/code><\/p>\n<p>That\u2019s it. You are all set.<\/p>\n<p><strong>Note: <\/strong><\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li>details on mysql privileges can be found <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/privileges-provided.html\">here<\/a><\/li>\n<li>Don\u2019t forget to open the default port 3306 if you want to access the database outside the ec2 instance boundary<\/li>\n<li>useful mysqld commands<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><code><\/code><\/p>\n<p><code><\/code><\/p>\n<ul>\n<li>sudo service mysqld start<\/li>\n<li>sudo service mysqld stop<\/li>\n<li>sudo service mysqld restart<\/li>\n<li>sudo service mysqld status<\/li>\n<\/ul>\n<\/div>\n<\/article>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"\n<p>Launch an EC2 instance of type Amazon Linux AMI from your aws console.<\/p>\n<p>SSH into your ec2 instance ssh -i ec2-user@my_ec2_ip_address<\/p>\n<p>Update the instance sudo yum update -y<\/p>\n<p>Install the mysqld server sudo yum install -y mysql55-server<\/p>\n<p>start the mysqld instance sudo service mysqld start<\/p>\n<p>the following command ensure launches mysqld on server restart [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7145"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7145"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7145\/revisions"}],"predecessor-version":[{"id":7146,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7145\/revisions\/7146"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}