MySQL Permission Replication

A little MySQL gotcha

So you’re working in a MySQL replication environment and you realise that you want to prevent your permissions replicating from your master to your slave.

MySQL replication filtering is client side so you logically decide that adding the following config to your my.cnf would stop filtering.

replicate-ignore-db = mysql

You happily perform a GRANT statement on your master database. Wait….what the…..my user has also been created on the slave!

You research and it turns out that in order to prevent MySQL permissions from replicating you have to specifically use wildcard filtering like so:

replicate-wild-ignore-table=mysql.%

Reference: http://dev.mysql.com/doc/refman/5.0/en/replication-features-userprivs.html

Git Post-Commit Dry Run Merge

Recently a member of our development team asked whether git version control included the ability to perform a dry run of a merge after making and committing changes. This led me to look at git hooks.

Working on a post commit hook, I wrote a hook that would allow the developer to identify (in realtime) whether the changes they had just made would conflict with any existing changes.

So I set about writing a post commit git hook…..and published my example on GitHub.

Example usage:

(hashes indicate user command and assumes that the hook file has been placed in the .git/hooks directory )

# mkdir GitCommitHookTest
# cd GitCommitHookTest
# git init

Initialized empty Git repository in ~/GitCommitHookTest

# echo -e "here is some content of a file" > somefile
# git add somefile
# git commit -a -m"My first commit"

[master (root-commit) 3b59d97] My first commit
 1 file changed, 1 insertion(+)
 create mode 100644 somefile

# git checkout -b some_other_branch

Switched to a new branch 'some_other_branch'

# echo "here is some more content in the file" >> somefile
# git commit -a -m"Another change to the file"

Dry run merge:

# master

Dry run merge of current branch (some_other_branch) with (master)

Merge result
------------
Already up-to-date.

Conflicts
---------


[some_other_branch 58addc8] Another change to the file
 1 file changed, 1 insertion(+)

The above example provides an idea of how the file can be executed.

I am a scripting n00b so I’m sure there are improvements that could be made to this. Feel free to fork my GitRepo and improve the code.