sunmingtao / sample-code

3 stars 4 forks source link

Can't open and lock privilege tables: Table 'mysql.user' doesn't exist #123

Closed sunmingtao closed 4 years ago

sunmingtao commented 4 years ago

Start mysql on windows with mysqld

2020-03-25T23:53:59.277885Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2020-03-25T23:53:59.279087Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200326 10:53:59
2020-03-25T23:53:59.281292Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-03-25T23:53:59.285784Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2020-03-25T23:53:59.286419Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2020-03-25T23:53:59.290230Z 0 [Warning] CA certificate ca.pem is self signed.
2020-03-25T23:53:59.291270Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2020-03-25T23:53:59.295229Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2020-03-25T23:53:59.296590Z 0 [Note] IPv6 is available.
2020-03-25T23:53:59.297223Z 0 [Note]   - '::' resolves to '::';
2020-03-25T23:53:59.298343Z 0 [Note] Server socket created on IP: '::'.
2020-03-25T23:53:59.301621Z 0 [Warning] Failed to open optimizer cost constant tables

2020-03-25T23:53:59.303791Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2020-03-25T23:53:59.306004Z 0 [ERROR] Fatal error: Failed to initialize ACL/grant/time zones structures or failed to remove temporary table files.
2020-03-25T23:53:59.307045Z 0 [ERROR] Aborting
sunmingtao commented 4 years ago
  1. Delete bin/data folder
  2. Run mysqld --initialize-insecure
  3. Run mysqld --console
  4. Open another cmd window and run mysql -u root to connect

https://stackoverflow.com/questions/34516664/cant-open-and-lock-privilege-tables-table-mysql-user-doesnt-exist