'Errors when connecting to MySQL local database

So, I have my local database, set it up, ran it from the windows services window. I open MySQL Workbench, and try to connect to the server. Hostname is localhost and username is root. I get something along the lines of access denied error. I try and run mysql.exe -u root -p.

It requires the password, I enter it, I get access denied error. I try adding --skip-grant-tables. I get a Can not perform keyring migration error. I try to run mysqld, and get keyring migration failed. I add --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" and it tells me

mysqld: File '.\binlog.index' not found (OS errno 13 - Permission denied)

And I have no idea what to do. Thanks in advance.

EDIT: I am just reinstalling MySQL

After a reinstall I am still getting the Can not perform keyring migration error.

Now I can't even run the service after a reinstall



Solution 1:[1]

SOLUTION:

I had to delete the data folder, run --initialize, then run mysqld -u mysql.

Solution 2:[2]

For those who have tried the accepted answer with no success. With the following error.

mysqld: Can't create directory 'C:\Program Files\MySQL\MySQL Server 8.0\data' (OS errno 13 - Permission denied)

Delete the data folder and make sure you run cmd as administrator before moving to the directory and running the initialize process.

It caused me a lot of time.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Big_Bad_E
Solution 2 Timilehin A.