stay windows Next :
Open the command line window , stop it mysql service :
net stop mysql
To mysql The installation path of mysql, stay bin Execute the command to start under the directory
mysqld --skip-grant-tables
Copy the command to the command line .
Then open the MySql, perform mysql, At this time, you can enter without entering a password .
use mysql update user set password=password(" New password ") where user="root"; flush privileges; exit
Use Task Manager , find mysqld-nt The process of , The end of the process !
It's restarting mysql-nt service , You can log in with your new password .
net start mysql
stay linux Next :
If MySQL Running , First of all, kill it
You can do that :
Stop database service
To the database installation directory , find my.ini , Open to find
[mysqld] Replace with [mysqld skip-grant-tables]
Start database service
Access to the database is no longer restricted
I recommend you to read more about “ mysql password To configure my.ini The server ” The article