MySQL Security is designed to prevent that. Try ...
Method #1
A. bring down the server
B. create mysql-init.sql in the mysql bin folder ...
insert into mysql.user set
host='localhost',
user='root',
plugin='mysal_native_password',
authentication_string=
CONCAT( '*', UPPER(SHA1(UNHEX(SHA1('your_password')))) ),
select_priv='Y',
Insert_priv='Y',
Update_priv='Y',
Delete_priv='Y',
Create_priv='Y',
Drop_priv='Y',
Reload_priv='Y',
Shutdown_priv='Y',
Process_priv='Y',
File_priv='Y',
Grant_priv='Y',
References_priv='Y',
Index_priv='Y',
Alter_priv='Y',
Show_db_priv='Y',
Super_priv='Y',
Create_tmp_table_priv='Y',
Lock_tables_priv='Y',
Execute_priv='Y',
Repl_slave_priv='Y',
Repl_client_priv='Y',
Create_view_priv='Y',
Show_view_priv='Y',
Create_routine_priv='Y',
Alter_routine_priv='Y',
Create_user_priv='Y',
Event_priv='Y',
Trigger_priv='Y' ;
C. flush privileges;
D. If it balks at the authentication_string settng, try ...
alter user 'root' IDENTIFIED BY 'your_password';
then the above cmd without the password, then ...
flush privileges;
E. Then ins a cmd window over the MySQL bin folder, run ...
mysqld --init-file=c:\\mysql-init.sql --console
F. login as root user.
or #2
https://dba.stackexchange.com/questions/7364/mysql-trying-to-create-root-user
or #3
https://stackoverflow.com/questions/50177216/how-to-grant-all-privileges-to-root-user-in-mysql-8-0
Edited 1 time(s). Last edit at 05/30/2022 10:42AM by Peter Brawley.