-1

By mistake I dropped mysql database which contains configuration for mysql service itself and now the service won't start. Here is the log at startup :

 100 200
2018-10-17T06:31:21.364556Z 0 [Warning] InnoDB: New log files created, LSN=2939944
wampmysqld64: Table 'mysql.plugin' doesn't exist
2018-10-17T06:31:21.748646Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2018-10-17T06:31:21.749764Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-10-17T06:31:21.754394Z 0 [Warning] Failed to open optimizer cost constant tables

2018-10-17T06:31:21.803432Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2018-10-17T06:31:21.804295Z 0 [ERROR] Aborting

Is there a way to restore it to the original without reinstalling everything (it was bundled in wamp server so I would have to reinstall everything).

Wicelo
  • 2,358
  • 2
  • 28
  • 44
  • Usually WAMP, XAMPP etc. will let you the option to not delete htdocs or your databases. In that way you can reinstall WAMP and import your databases. Could you look up that directory? EDIT: A very simmilar question: [How to recover/recreate mysql's default 'mysql' database](https://stackoverflow.com/questions/8911115/how-to-recover-recreate-mysqls-default-mysql-database) – Cataklysim Oct 17 '18 at 06:39
  • @Cataklysim thanks it worked, I saw this thread but one can onlye execute the command if the `data ` folder is entirely deleted first. – Wicelo Oct 17 '18 at 07:02
  • Thats good to hear. Didn't know that the `data` folder has to be empty. Could you post your entire solution step by step as answer for user with the same problem? – Cataklysim Oct 17 '18 at 07:29
  • @Cataklysim yes if data exists `mysqld.exe` will yield an error stating that the folder is not empty. – Wicelo Oct 17 '18 at 08:26

1 Answers1

1

To restore fresh mysql system after accidental removal of a system database you have to :

  1. Rename or delete the data folder in mysql install folder otherwise the next step will yield an error.
  2. Run one of these commands from windows console :

    C:> bin\mysqld.exe --initialize

    C:> bin\mysqld.exe --initialize-insecure

Wicelo
  • 2,358
  • 2
  • 28
  • 44