Mysql failed to start, and I got these errors
160405 8:58:33 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
160405 08:58:33 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
So I killed the mysql server if it was running killall mysql
Then granted permission to mysql user and group so it can have access rights to the directory.
chown -R mysql /var/lib/mysql
chgrp -R mysql /var/lib/mysql
Then I restarted mysql server using sudo service mysql restart
Server did not start and I saw another set of errors :(
160405 11:29:11 [ERROR] Plugin 'InnoDB' init function returned error.
160405 11:29:11 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
160405 11:29:11 [ERROR] Unknown/unsupported storage engine: InnoDB
160405 11:29:11 [ERROR] Aborting
I removed all the log files and ibdata1 files.
rm /var/lib/mysql/ib_logfile0
rm /var/lib/mysql/ib_logfile1
rm /var/lib/mysql/ibdata1
I tried restarting the server again and I got another set of errors. Poor me :'(
160405 11:32:28 InnoDB: Waiting for the background threads to start
160405 11:32:29 InnoDB: 5.5.47 started; log sequence number 0
160405 11:32:29 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
160405 11:32:29 [Note] - '0.0.0.0' resolves to '0.0.0.0';
160405 11:32:29 [Note] Server socket created on IP: '0.0.0.0'.
160405 11:32:29 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
Then I tried running
mysql_install_db --user=mysql --ldata=/var/lib/mysql/
Restarted mysql server again and it worked!