Mysql crashed and won't start up
Solution 1:
Ouch.
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html
InnoDB: about forcing recovery.
Check the suggested webpage: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html.
Basically, try to start the MySQL server in a recovery mode and make a backup of your crashed tables.
Edit your /etc/my.cnf
and add:
innodb_force_recovery = 1
...to see if you can get into your database and get your data / find the corrupted table.
Usually, when this happens it's a re-build (at least of a corrupted table or two).
From http://chepri.com/mysql-innodb-corruption-and-recovery/:
- Stop
mysqld
(service mysql stop
). - Backup
/var/lib/mysql/ib*
Add the following line into
/etc/my.cnf
:innodb_force_recovery = 1
(they suggest 4, but its best to start with 1 and increment if it won't start)
Restart
mysqld
(service mysql start
).- Dump all tables:
mysqldump -A > dump.sql
- Drop all databases which need recovery.
- Stop
mysqld
(service mysql stop
). - Remove
/var/lib/mysql/ib*
- Comment out
innodb_force_recovery
in/etc/my.cnf
- Restart
mysqld
. Look at mysql error log. By default it should be/var/lib/mysql/server/hostname.com.err
to see how it creates newib*
files. - Restore databases from the dump:
mysql < dump.sql
Solution 2:
I was facing this same error while using mysql:5.7 docker image. Main mistake was trying to create root user which exists by default. More information: https://github.com/docker-library/mysql/issues/129
As given in the above link, solution was to NOT set MYSQL_USER and MYSQL_PASSWORD in the environment variables while starting the docker image.