title: Fix MySQL Server data directory
body: <p>I have a very weird Problem on Windows 10 with MySQL Server 8: </p>
  
  <p>I could not start the mysql server or service with 
  <code>mysqld</code> or <code>net start mysql</code> as mysql reported a missing <strong>data</strong> directory (it could not write a 'test file'). It is/was looking in <code>C:\Program Files\MySQL\MySQL Server 8.0</code>.</p>
  
  <p>After some googling I could start the mysql server after running
  <code>mysqld --initialize</code>, which did create a <strong>data</strong> folder beneath <code>C:\Program Files\MySQL\MySQL Server 8.0</code> and reseted the password somehow. Unfortuneatly, all my databases are gone after I connect to the (I think so) newly initialized mysql server.</p>
  
  <p>After some more googling I found, that there is the following directory on my PC:
  <code>C:\ProgramData\MySQL\MySQL Server 8.0</code> 
  ... and voilà .. inside that <strong>Data</strong> directory there are folders with names of my (lost) databases. So I am pretty sure, that my data is in there.</p>
  
  <p>But how do I set up the mysql server to use this correct data/settings whatever. I do not want to use a newly initialized mysql server.</p>
  
  <p>I tried copying the folders from <code>C:\ProgramData\MySQL\MySQL Server 8.0</code> to <code>C:\Program Files\MySQL\MySQL Server 8.0</code> but with no luck. One time the server could not be started, on the other occasion the data was just ignored.
  I also tried to copy a my.ini to <code>C:\ProgramData\MySQL\MySQL Server 8.0</code> and change the datadir entry beneath [mysqld] -> No luck.</p>
  
  <p>Any help is appreciated.</p>
  
  <p>UPDATE:</p>
  
  <p>The following errors and warnings appear in my ".err" file:</p>
  
  <p>2020-03-11T19:21:10.658537Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.</p>
  
  <p>2020-03-11T19:21:10.659813Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.19) starting as process 4040</p>
  
  <p>2020-03-11T19:21:11.340219Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.</p>
  
  <p>2020-03-11T19:21:11.358861Z 0 [Warning] [MY-013143] [Server] Column count of mysql.user is wrong. Expected 51, found 49. The table is probably corrupted</p>
  
  <p>2020-03-11T19:21:11.359562Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.db. The table is probably corrupted!</p>
  
  <p>2020-03-11T19:21:11.360108Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.tables_priv. The table is probably corrupted!</p>
  
  <p>2020-03-11T19:21:11.360680Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.tables_priv. The table is probably corrupted!</p>
  
  <p>2020-03-11T19:21:11.361259Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.columns_priv. The table is probably corrupted!</p>
  
  <p>2020-03-11T19:21:11.361881Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.procs_priv. The table is probably corrupted!</p>
  
  <p>2020-03-11T19:21:11.362474Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.procs_priv. The table is probably corrupted!</p>
  
  <p>2020-03-11T19:21:11.363076Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.proxies_priv. The table is probably corrupted!</p>
  
  <p>2020-03-11T19:21:11.363713Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.proxies_priv. The table is probably corrupted!</p>
  
  <p>2020-03-11T19:21:11.364309Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.proxies_priv. The table is probably corrupted!</p>
  
  <p>2020-03-11T19:21:11.364908Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.role_edges. The table is probably corrupted!</p>
  
  <p>2020-03-11T19:21:11.365505Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.role_edges. The table is probably corrupted!</p>
  
  <p>2020-03-11T19:21:11.366123Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.default_roles. The table is probably corrupted!</p>
  
  <p>2020-03-11T19:21:11.366774Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.default_roles. The table is probably corrupted!
  2020-03-11T19:21:11.367391Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.global_grants. The table is probably corrupted!</p>
  
  <p>2020-03-11T19:21:11.368010Z 0 [Warning] [MY-013139] [Server] Cannot load from mysql.password_history. The table is probably corrupted!
  2020-03-11T19:21:11.369081Z 0 [ERROR] [MY-013139] [Server] Cannot load from mysql.global_grants. The table is probably corrupted!</p>
  
  <p>2020-03-11T19:21:11.369779Z 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.</p>
  
  <p>2020-03-11T19:21:11.371103Z 0 [ERROR] [MY-010119] [Server] Aborting</p>
  
  <p>2020-03-11T19:21:12.355716Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.19)  MySQL Community Server - GPL.</p>
  
  <p>I tried to run <strong>mysql_upgrade</strong>, which just tells me, that it cannot be run because the upgrade tool is deprecated..</p>