読者です 読者をやめる 読者になる 読者になる

Fatal error: Can't open and lock privilege tables: Incorrect file format 'user'

ubuntuサーバで動かしていたmysqlが落ちてた。
しかも立ち上がらない。

エラーログ

$ cat /var/log/mysql/error.log
140208 21:11:32 [Note] Plugin 'FEDERATED' is disabled.
140208 21:11:32  InnoDB: Initializing buffer pool, size = 8.0M
140208 21:11:32  InnoDB: Completed initialization of buffer pool
140208 21:11:32  InnoDB: Started; log sequence number 0 254748912
140208 21:11:32 [ERROR] Fatal error: Can't open and lock privilege tables: Incorrect file format 'user'


動かすまでのメモ

$ cd /var/lib/mysql/
$ tar czf /root/mysql.tgz mysql
$ cd mysql
$ rm -rf *
$ mysql_install_db
$ sudo  mysql_install_db

Installing MySQL system tables...
140208 21:18:18 [Warning] '--default-character-set' is deprecated and will be removed in a future release. Please use '--character-set-server' instead.
OK
Filling help tables...
140208 21:18:18 [Warning] '--default-character-set' is deprecated and will be removed in a future release. Please use '--character-set-server' instead.
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h hostname password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/scripts/mysqlbug script!

$ /usr/bin/mysqladmin -u root password '***************'

これで起動した