0

I run mysql in Ubuntu 20.04 under wsl2.

Today, when I started windows, it started in recovery mode "Recovery: It looks Windows hasn't loaded properly...", like it does time to time. After reboot mysql does not start anymore. Everything else seems to work fine.

Mysql service start error:

$ sudo service mysql start
 * Starting MySQL database server mysqld
su: warning: cannot change directory to /nonexistent: No such file or directory        [fail]

Error log /var/log/mysql/error.log

2022-09-28T06:49:48.096514Z 0 [Warning] [MY-013143] [Server] Column count of mysql.user is wrong. Expected 51, found 37. The table is probably corrupted
2022-09-28T06:49:48.096523Z 0 [Warning] [MY-013143] [Server] Column count of mysql.db is wrong. Expected 22, found 20. The table is probably corrupted
2022-09-28T06:49:48.096528Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.tables_priv. The table is probably corrupted!
2022-09-28T06:49:48.096532Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.tables_priv. The table is probably corrupted!
2022-09-28T06:49:48.096535Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.tables_priv. The table is probably corrupted!
2022-09-28T06:49:48.096540Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.tables_priv. The table is probably corrupted!
2022-09-28T06:49:48.096544Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.columns_priv. The table is probably corrupted!
2022-09-28T06:49:48.096547Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.columns_priv. The table is probably corrupted!
2022-09-28T06:49:48.096551Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.procs_priv. The table is probably corrupted!
2022-09-28T06:49:48.096554Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.procs_priv. The table is probably corrupted!
2022-09-28T06:49:48.096558Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.procs_priv. The table is probably corrupted!
2022-09-28T06:49:48.096644Z 0 [ERROR] [MY-010316] [Server] Fatal error: Could not read the column 'authentication_string' from table 'mysql.user'. Please perform the MySQL upgrade procedure.
2022-09-28T06:49:48.096679Z 0 [ERROR] [MY-010952] [Server] The privilege system failed to initialize correctly. For complete instructions on how to upgrade MySQL to a new version please see the 'Upgrading MySQL' section from the MySQL manual.
2022-09-28T06:49:48.096713Z 0 [ERROR] [MY-010119] [Server] Aborting

I am able to start mysql if I add /etc/mysql/mysql.conf.d/mysqld.cnf

[mysqld]
skip_grant_tables

But when I run mysqlcheck, everything seems to be OK

$ sudo mysqlcheck --databases mysql
mysql.columns_priv                                 OK
mysql.component                                    OK
mysql.db                                           OK
mysql.default_roles                                OK
mysql.engine_cost                                  OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.global_grants                                OK
mysql.gtid_executed                                OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.host                                         OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.password_history                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.replication_asynchronous_connection_failover OK
mysql.replication_asynchronous_connection_failover_managed OK
mysql.replication_group_configuration_version      OK
mysql.replication_group_member_actions             OK
mysql.role_edges                                   OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK

Also with --check-upgrade flag everything is up to date.

$ sudo mysqlcheck --check-upgrade --databases mysql
mysql.columns_priv                                 Table is already up to date
...
mysql.user                                         Table is already up to date

Is there any way to fix this? Or should I just go for reinstalling mysql?

Tola
  • 101
  • 1

1 Answers1

0

Database was corrupted after I imported database from old mysql dump that had binary data on it.

Not sure If it was related, but when I opened sql-dump file with VsCode, it had "␁" (Start of heading) characters on it:

Sql emojis

Problem was fixed after I exported all databases, did full reinstall to mysql and imported data back without the corrupted database.

Tola
  • 101
  • 1