Search code examples
mysql

MySQL Error Even Purging and Reinstalling does not fix it


I accidentally began dropping Grant Tables from the "mysql" database I dropped several before I realised what I was doing.

When I tried accessing the mysql shell obviously it would no longer allow me access.

I decided to just purge and reinstall mysql.

However, now mysql will not startup.

When I run:

service mysql start

I get:

Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.

Checking the logs under:

/var/log/mysql/error.log I get:

[ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-001146 - Table 'mysql.component' doesn't exist

And

[ERROR] [MY-010326] [Server] Fatal error: Can't open and lock privilege tables: Table 'mysql.db' doesn't exist

Does anyone know I can regenerate these missing tables?

=====Edit=====

/etc/mysql/mysql.conf.d/mysqld.cnf doesn't exist.

Solution

  • I solved it.

    From here:

    How to recover/recreate mysql's default 'mysql' database

    I ran:

    rm /var/lib/mysql -rf
    mkdir /var/lib/mysql
    chown mysql:mysql /var/lib/mysql
    mysqld --initialize
    

    But my /etc/mysql was a bit messed up so I purged mysql again. When I reinstalled everything is running okay now.