What's New in Edge Rails: DB Console 10

Posted by ryan
at 4:39 PM on Tuesday, May 13, 2008



For those of you that haven’t committed the database username and passwords for your many apps to memory yet, there comes some help from edge Rails – the addition of a dbconsole script that will automatically drop you into a database prompt using the info in config/database.yml configuration.

In an edge rails app that has a mysql db config:

Update: Because of the insecure nature of passing in the password on the command line on shared hosts – you now need to use the -p or --include-password option to force the password to be read from your config file.

script/dbconsole -p
...
mysql>

And there I am, logged into the dev database in the mysql command prompt. No scrounging around for that app-specific username or db name or cat ing the config/database.yml file anymore.

tags: ruby, rubyonrails

Comments

Leave a response

  1. Robby RussellMay 13, 2008 @ 06:27 PM

    Yay!

    No more… cat config/database.yml to grab the username and password. :-)

  2. Jordi BunsterMay 13, 2008 @ 09:14 PM

    This leaves the MySQL password in the output of ps. The same is true in the case of the environment variable used for postgres.

  3. Steve PurcellMay 14, 2008 @ 01:39 AM

    Yep, and my db_console plugin (from whence this script came) provides this functionality for non-Edge Rails users.

    Jordi—if you know of an alternative technique for giving the password to mysql, then let me know. The environment variable trick should be secure, if I understand correctly.

  4. Bruno MichelMay 14, 2008 @ 05:14 AM

    Steve : environment is NOT secure (it’s the same than passing it on the command line). A better solution should be to use .my.cnf file.

    http://dev.mysql.com/doc/refman/5.0/en/password-security.html is a good source of informations about it.

  5. Luke RedpathMay 14, 2008 @ 07:52 AM

    Nice to see this in edge, been doing this for a while now with a simple Rake task.

    @Jordi: unless you’re using this on a shared server, I don’t think it’s much of an issue. If you’re using this on your own production servers, people seeing the password in the ps list should be the last of your worries. Using it locally, I couldn’t care less if people can see my password in the ps as I use a generic password for my local database and it doesn’t contain any sensitive/important information.

  6. ZsomborMay 15, 2008 @ 05:19 AM

    In Emacs I’ve do a “C-c C-c s s RET” get the same thing … or actually better as you can’t compare a dumb prompt (readline or not) with the power of an emacs buffer.

  7. railsmonkMay 15, 2008 @ 10:11 AM

    Nice stuff!

  8. Babble OnMay 24, 2008 @ 07:01 PM

    Any security issues aside, this is a real time-saver during development.

    Also, I haven’t used this particular method yet, but last time I checked when passing the MySQL password on the command-line, it obscured it, replacing the actual characters with something along the lines of ‘xxxxx’.

  9. jtMay 26, 2008 @ 02:25 AM

    Cc Cc s s RET – Super combo!

  10. Nick RetallackJuly 14, 2008 @ 06:42 PM

    Why not give mysql the -p option and then feed it the password through stdin?

Comment