0

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.
nbk
  • 45,398
  • 8
  • 30
  • 47
KeyboardNinja
  • 71
  • 1
  • 2
  • 11
  • https://stackoverflow.com/questions/8911115/how-to-recover-recreate-mysqls-default-mysql-database – Garr Godfrey Oct 13 '21 at 19:53
  • 1
    Does this answer your question? [How to recover/recreate mysql's default 'mysql' database](https://stackoverflow.com/questions/8911115/how-to-recover-recreate-mysqls-default-mysql-database) – Garr Godfrey Oct 13 '21 at 19:54
  • @GarrGodfrey When I run: mysqldump --routines databasename > outfile.sql I get: mysqldump: Got error: 2013: Lost connection to MySQL server at 'reading initial communication packet', system error: 104 when trying to connect – KeyboardNinja Oct 13 '21 at 19:55
  • @GarrGodfrey And running: mysqld --initialize gives me: 2021-10-13T19:56:20.679309Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.26-0ubuntu0.20.04.3) initializing of server in progress as process 288419 2021-10-13T19:56:20.681026Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting. 2021-10-13T19:56:20.681030Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it. 2021-10-13T19:56:20.681077Z 0 [ERROR] [MY-010119] [Server] Aborting – KeyboardNinja Oct 13 '21 at 19:58
  • 2021-10-13T19:56:20.681177Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.26-0ubuntu0.20.04.3) (Ubuntu). – KeyboardNinja Oct 13 '21 at 19:58
  • show what you did to purge and reinstall – ysth Oct 13 '21 at 19:58
  • you probably need the answer from kungfooman. The long one about moving your db files out of data directory and recreating everything – Garr Godfrey Oct 13 '21 at 19:58
  • @ysth: sudo apt-get remove --purge mysql-server mysql-client mysql-common – KeyboardNinja Oct 13 '21 at 20:03
  • @GarrGodfrey I have an issue with: /etc/mysql/mysql.conf.d/mysqld.cnf It doesn't exist – KeyboardNinja Oct 13 '21 at 20:12

1 Answers1

1

I solved it.

From here:

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

I ran:

/etc/init.d/mysql stop 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.

KeyboardNinja
  • 71
  • 1
  • 2
  • 11