Wednesday, May 26, 2010

MySQL User Access Setup

Setting up a database to be populated by Hibernate or some other O/R mapping tool usually requires the following inital setup when working with MySQL:
  1. Create the database, e.g.

    mysqladmin -u root -p create foo

  2. Create a user and grant full access to the database from any machine, e.g.

    grant all on foo.* to 'homer'@'%' identified by 'simpson';
    grant all on foo.* to 'homer'@'localhost' identified by 'simpson';

  3. You can always undo these permissions, e.g.

    revoke all on foo.* from 'homer'@'%';
    revoke all on foo.* from 'homer'@'localhost';

Of course, there is a ton of documentation available to grant more fine-grained privileges and much more.

Monday, May 24, 2010

Subversion Patches

Sometimes I need to create a patch for the local changes of my Subversion working copy. This can be achieved very easily using the following command (typically issued from the root directory of the checkout):

svn diff > ~/local_changes.diff

The patch can then be applied on a different working copy by applying the command:

patch -p0 -i ~/local_changes.diff

The command output will tell which parts of the patch have been applied successfully and which ones, if any, have failed.

If you work with IntelliJ IDEA, I suggest you both create and apply the patch with IDEA, since patches created by Subversion do not work well when applied in IDEA.