Homebrewでインストールしたmysqlのmysql_install_dbが失敗する

brew install mysql

はうまくいっていて、その後のmysql_install_dbで失敗してしまう。

mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

を実行すると・・

Installing MySQL system tables...
131106 21:00:15 [ERROR] /usr/local/opt/mysql/bin/mysqld: Incorrect information in file: './mysql/tables_priv.frm'
ERROR: 1033  Incorrect information in file: './mysql/tables_priv.frm'
131106 21:00:15 [ERROR] Aborting

131106 21:00:15 [Note] /usr/local/opt/mysql/bin/mysqld: Shutdown complete


Installation of system tables failed!  Examine the logs in
/usr/local/var/mysql for more information.

You can try to start the mysqld daemon with:

    shell> /usr/local/opt/mysql/bin/mysqld --skip-grant &

and use the command line tool /usr/local/opt/mysql/bin/mysql
to connect to the mysql database and look at the grant tables:

    shell> /usr/local/opt/mysql/bin/mysql -u root mysql
    mysql> show tables

Try 'mysqld --help' if you have problems with paths.  Using --log
gives you a log in /usr/local/var/mysql that may be helpful.

Please consult the MySQL manual section
'Problems running mysql_install_db', and the manual section that
describes problems on your OS.  Another information source are the
MySQL email archives available at http://lists.mysql.com/.

Please check all of the above before mailing us!  And remember, if
you do mail us, you MUST use the /usr/local/opt/mysql/scripts/mysqlbug script!

原因は何度かbrew install mysqlbrew install mysql55を実行していたので、 /usr/local/varディレクトリに不必要なファイルが残っていたからのようだ。

sudo rm -rf /usr/local/var/mysql*

を実行してから再度mysql_install_dbを実行することで無事インストールができました。

[24時間365日] サーバ/インフラを支える技術 ?スケーラビリティ、ハイパフォーマンス、省力運用 (WEB+DB PRESS plusシリーズ)

[24時間365日] サーバ/インフラを支える技術 ?スケーラビリティ、ハイパフォーマンス、省力運用 (WEB+DB PRESS plusシリーズ)