How do I start MySQL server in an Amazon AWS Elastic Beanstalk instance?

James S asked:

I am relatively new LAMP dev who is trying to learn Linux primarily through AWS. I have a live Elastic Beanstalk instance up and running. I did a yum install of the following packages:

mysql55.x86_64 mysql55-bench.x86_64 mysql55-common.x86_64 mysql55-devel.x86_64 mysql55-libs.x86_64 mysql55-server.x86_64 mysql55-test.x86_64 

Which all seemed to install fine … then typed …

mysql -V 

which gets me

mysql Ver 14.14 Distrib 5.5.20, for Linux (x86_64) using readline 5.1 

… which confirms mysql is installed … but then when I type …

mysql -u ec2-user -p
Enter password: /*leaving blank*/

I get …

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Now the thing is I am ssh-ing into this server with a Security Group key pair I created in AWS Console. So the key is authenticating me (from the .ppk file) when I log into the box as ec2-user. That IS my “root” user as far as I know, there is no password, but I may be mistaken.

So, basically I don’t understand the basics of how to begin using MySQL in a linux environment. I’ve only really used PHPMyAdmin and the MySQL command line from WAMP until now.

Can somebody help me with where I’m getting my wires crossed here?

My answer:


It’s not intended for you to run MySQL on your Elastic Beanstalk instance. If you need to use MySQL, you are supposed to run it on a separate instance, or use Amazon RDS. The reason for this is that your instance is not persistent and can be restarted at any time without warning from the original AMI. If that happens, goodbye database.

There’s an extended discussion of this issue on the AWS forums.

That said, if you’re just testing, jnizjo’s instructions will get the MySQL server up and running for you.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.