Think about what you are doing before you do this. Don’t be stupid.
> cp -R /usr/local/mysql/data /usr/local/var/mysql
> brew install mysql
> cp /usr/local/Cellar/mysql/5.1.51/com.mysql.mysqld.plist ~/Library/LaunchAgents
> launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
**optional** > rm -rf /usr/local/mysql