简体   繁体   中英

How to reset mySql root password

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 Files\MySQL\MySQL Server 8.0>mysqld --init-file=C:\\mysql-init.txt --console
2021-12-16T18:33:22.801467Z 0 \[System\] \[MY-010116\] \[Server\] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.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 Files\MySQL\MySQL Server 8.0\data\mysqld_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 Files\MySQL\MySQL Server 8.0\data\mysqld_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 Files\MySQL\MySQL Server 8.0\data\' (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 Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.26)  MySQL Community Server - GPL.][1]][1]

For windows 10

  1. Delete Data folder present inside C:\\Program Files\\MySQL\\MySQL Server 8.0

  2. Create file named mysql-init.txt and copy paste below lines and store at C:\\

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

  3. Open CMD as admin cd to path C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin> and enter following commands one by one

mysqld -install

mysqld --initialize

mysqld --init-file=C:\\\\mysql-init.txt --console

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM