Reputation: 3749
I'm using rubber to deploy a rails application and am having trouble connecting to MySQL. Do I have to manually setup MySQL on EC2 or should Rubber have already had done that? While this isn't all that helpful, here is log output when rake is ran:
** [out :: db01.memepluspl.us] rake aborted!
** [out :: db01.memepluspl.us]
** [out :: db01.memepluspl.us] Access denied for user ''@'db01.memepluspl.us' to database 'meme_plus_plus_production'
** [out :: db01.memepluspl.us]
** [out :: db01.memepluspl.us]
** [out :: db01.memepluspl.us] Tasks: TOP => db:migrate => environment
Upvotes: 2
Views: 1010
Reputation: 4427
If anyone else is having this problem, it is because mysql now has default anonymous users added with limited access.
The problem is discussed here.
The first solution there is not comprehensive enough, you need the one at the end which deletes all anonymous users (not just localhost). This is because MYSQL will authenticate on HOST before the USER, so a anonymous user ''@'your.host.com' will take priority over 'dbuser'@'your.host.com' (documented in mysql documentation) and rubber will be trying to connect with the full hostname.
Edit your ./config/rubber/deploy-mysql.yml:
rubber.sudo_script "create_master_db", <<-ENDSCRIPT
mysql -u root -e "create database #{env.db_name};"
mysql -u root -e "delete from mysql.user where user='';" <<-- ADD THIS LINE
...
ENDSCRIPT
Upvotes: 2
Reputation: 1962
in my case, the app name I had input in rubber.yml was actually different then the actual app name(the project files retains placeholder name)...
I ssh'd into the instance, looked for current/
and cat config/database.yml
then just tried running the connect command rake would try to run from the stuff there and the error was there, so I'd suggest trying to better debug what's going on
I guessed I had to change the rubber-mysql.yml configs... Im recreating the staging stuff now, I think it should at least pass through this issue.. gl
Upvotes: 1
Reputation: 21140
I'm not familiar with Rubber at all so I don't know if it should have created your MySQL account for you, but here is how to do it manually:
mysql -u root
mysql> grant all on meme_plus_plus_production.* to 'user'@'db01.memepluspl.us' identified by 'password';
mysql> flush privileges;
mysql> exit;
You may need to enter a password for the MySSQL root account; for example, on Ubunutu the default is "password".
Note also that my example grants full read and write privileges to every table in the database to the specified user. Look up the MySQL grant command if you want to use reduced privileges.
Upvotes: 0
Reputation: 5649
I don't know rudder much but it looks it's missing some configuration. There is no user specified and probably no password either.
Upvotes: 0