mysql permissions problem workaround?

2 views
Skip to first unread message

jfrankov

unread,
Dec 2, 2009, 7:56:47 PM12/2/09
to ec2-on-rails-discuss
I've been having a lot of headaches trying to understand how mysql and
the ec2onrails gem want to use permissions for root vs. non-root
users. Unfortunately, I'm out of patience and time. Is there any
reason why adding skip-grant-tables to the /etc/mysql/my.cnf wouldn't
sidestep the entire problem?

I ask because I tried it, but then mysql mysteriously wouldn't start
up. Nothing in the regular or error log about why, just a "fail!"
after running /etc/init.d/mysql.

I don't mean to complain; I've used ec2onrails for almost a couple
years now and like it a lot- this is the only issue that always messes
up my deploys and it seems to cause problems for a lot of other people
too.

Is there an ACCURATE set of steps to get permissions running properly,
OR is there a way to turn off mysql permissions entirely?

All help and ideas are really appreciated!

Thanks,
-Jason

jfrankov

unread,
Dec 3, 2009, 7:26:33 PM12/3/09
to ec2-on-rails-discuss
I figured it out. In the spirit of "light a candle instead of cursing
the darkness" I heavily cribbed and edited Paul D's README file to
create what I think is a detailed and accurate set of steps about how
to set up ec2onrails to work right with mysql permissions:

1. Install the gem

# sudo gem install ec2onrails

2. Add the config files to your Rails app

You will need to place Capfile in the root of your rails folder, and
put deploy.rb and s3.yml in the config folder. Within your rails
directory, run:


wget -q -O Capfile http://github.com/pauldowman/ec2onrails/raw/master/examples/Capfile

wget -q -O config/deploy.rb http://github.com/pauldowman/ec2onrails/raw/master/examples/deploy.rb

wget -q -O config/s3.yml http://github.com/pauldowman/ec2onrails/raw/master/examples/s3.yml

Be sure to customize those files and read the comments before going to
the next step.

3. Edit database.yml

In your database.yml file, add host: db_primary to the host of the the
environment you want to run on the instance, usually "production".

Also, make sure you choose a new username and password for that same
environment. Ec2OnRails will use whatever username and password you
put there to make mysql user permissions for accessing the database on
the instance. Important: Do not use "root" for the username or you
will mess everything up.

4. Start up one or more instances of the image.

If you’ve started EC2 instances before you can skip this section.
Otherwise, I’m not going to lie, this part is complicated and will
take long time on your first try.

For the AMI id’s of the current images do cap ec2onrails:ami_ids from
within the app that you configured in the previous step (they’re also
listed earlier on this page).

NOTE: Only use the images that match the current version of the gem.

5. Setup server roles

Run:

# cap ec2onrails:server:set_roles

6. Copy your public key from the server to keep Capistrano happy

This is a workaround for a quirk in Capistrano. From within the root
of your rails app do:

cap ec2onrails:get_public_key_from_server

Note, this will only work if you have an external ssh command in the
path, it won’t work for most Windows users.

7. Do NOT run cap ec2onrails:db:set_root_password!

If you run it now, before cap ec2onrails:setup, you will basically
f*** the mysql config on the instance. To be safe, comment out the
line in the deploy.rb that says :mysql_root_password.

8. Deploy the app with Capistrano

Now that the gem is installed, your deploy.rb is configured and you
can start and stop EC2 instances, this is the only thing you’ll need
to do from now on.

cap ec2onrails:setup
cap deploy:migrations

Then, it's all cap deploy from here going forward.

I hope this helps someone. Thanks again to Paul for all his hard work
and help to the Rails community.

-Jason

Paul Dowman

unread,
Dec 8, 2009, 9:49:52 PM12/8/09
to ec2-on-rai...@googlegroups.com
Thanks, I'll update the instructions.

Paul


-Jason

--

You received this message because you are subscribed to the Google Groups "ec2-on-rails-discuss" group.
To post to this group, send email to ec2-on-rai...@googlegroups.com.
To unsubscribe from this group, send email to ec2-on-rails-dis...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ec2-on-rails-discuss?hl=en.



Reply all
Reply to author
Forward
0 new messages