Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to uninstall mysql on amazon ec2 micro instance

Somehow I have screwed up mysql on my ec2 micro instance on amazon. Ho wdo i uninstall it and reinstall a fresh mysql on the machine?

Please help me to get this done.

Regards, Pradeep

like image 664
Pradeep Avatar asked Aug 20 '13 15:08

Pradeep


2 Answers

If you are using RHEL or Amazon's AMI:

sudo yum -y remove mysql-server

and

sudo yum -y install mysql-server

should do it.

like image 85
Suman Avatar answered Oct 06 '22 17:10

Suman


For right now:

Assuming you don't need to keep any data, you can terminate your instance and launch a new one and configure it to your liking.

To prevent problems in the future:

After you launch your new instance and configure it with MySQL and whatever else you may need, create an Amazon Machine Image (AMI) of the instance. You can launch an instance based on your AMI so you don't have to go through and manually configure the instance from scratch if something were to happen. You shouldn't have to update AMIs too often. I usually only do when there are updates to the OS or something else on the machine.

When it comes to persisting data/code the first thing I recommend is looking into some kind of source control system like git. On top of that you can create Snapshots of the Volume attached to your instance. That way if something bad happens with the data in your current Volume you can launch a new Volume based on the Snapshot you created. Small warning, the data on the Snapshot will only be as up to date as the last time you created the Snapshot, so if you're changing a lot of things, you're going to want to create regular Snapshots. Every time you update a Snapshot, it does so incrementally. Snapshots are stored on S3 which typically has a very low failure rate, so your Snapshots are pretty safe.

You also need to find a way to manage your Snapshots and AMIs that will work for you. There are a lot of paid solutions for this, or you can write a script in house. The level of detail you need will probably decide which is better for you. I'll add a link if I come across anything open source.

Here are some links that may help you put this all together:

Snapshots Doc
Volumes Doc
AWS Backup and Recovery Whitepaper PDF
SO on How to Use Git

Let me know if you need anything clarified, thanks!

like image 45
EFeit Avatar answered Oct 06 '22 17:10

EFeit