'How to gain access back to root (admin) user in MySQL?

I had one admin user with username = root (had admin privileges) and password =admin then i created new user with username =root (have no privileges) and password =root. but what happened now I have lost access to root user(admin) and i am able to access only root user which is newly created.now i am unable to do anything with this newly created root user. it show access denied for every operation. so is there any way to gain access to root(admin) user or give admin privileges to new root user or reset databases and start by new. I tried many solution but none of them worked for me.



Solution 1:[1]

Complete account name includes both username part and host part. See Specifying Account Names and the difference between USER() and CURRENT_USER().

Check complete names for both root accounts. Then log in by the way which makes "old" root account matched one only.

For example, if "old" is 'root'@'%' and "new" is 'root'@'localhost' or 'root'@'127.0.0.1' then disable network connections (--skip-networking=ON in the service command line) and connect using named pipes or shared memory (on Windows) or Unix socket files (on Unix). Or connect to the server remotely.

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 Akina