refactor mysql resource