How to reset mysql root password?

244    Asked by ClareMatthews in SQL Server , Asked on Mar 14, 2023

I tried resetting mySql password using official documentation but its not working,


https://dev.mysql.com/doc/mysql-windows-excerpt/5.7/en/resetting-permissions-windows.html


its giving me error

[![C:Program FilesMySQLMySQL Server 8.0>mysqld --init-file=C:\mysql-init.txt --console
2021-12-16T18:33:22.801467Z 0 [System] [MY-010116] [Server] C:Program FilesMySQLMySQL Server 8.0binmysqld.exe (mysqld 8.0.26) starting as process 14656
2021-12-16T18:33:22.803505Z 0 [Warning] [MY-010091] [Server] Can't create test file C:Program FilesMySQLMySQL Server 8.0datamysqld_tmp_file_case_insensitive_test.lower-test
2021-12-16T18:33:22.803577Z 0 [Warning] [MY-010091] [Server] Can't create test file C:Program FilesMySQLMySQL Server 8.0datamysqld_tmp_file_case_insensitive_test.lower-test
2021-12-16T18:33:22.803754Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to 'C:Program FilesMySQLMySQL Server 8.0data' (OS errno: 2 - No such file or directory)
2021-12-16T18:33:22.804645Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-12-16T18:33:22.804771Z 0 [System] [MY-010910] [Server] C:Program FilesMySQLMySQL Server 8.0binmysqld.exe: Shutdown complete (mysqld 8.0.26)  MySQL Community Server - GPL.][1]][1]


Answered by David Edmunds

To reset mysql root password in windows 10


Delete Data folder present inside C:Program FilesMySQLMySQL Server 8.0
Create a file named mysql-init.txt and copy paste below lines and store at C:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
Open CMD as admin cd to path C:Program FilesMySQLMySQL Server 8.0in> and enter following commands one by one
mysqld -install
mysqld --initialise
mysqld --init-file=C:\mysql-init.txt --console


Your Answer

Interviews

Parent Categories