Reset the root password for mysql and set the root password for mysql.
Recently, mysql was used in another project. Since mysql was installed a long time ago, the root password was forgotten.
Windows:
1. log in as a system administrator;
2. Stop the MySQL service;
3. Go to CMD and enter the MySQL installation directory, for example, D:/MySQL Server 5.0 /;
4. Skip the permission check and start MySQL,
D:/MySQL Server 5.0/bin/mysqld-nt -- skip-grant-tables
5. Open a new CMD and enter D:/MySQL Server 5.0/bin /,
Reset the root password
D:/MySQL Server 5.0/bin/mysqladmin-uroot flush-privileges password "newpassword"
D:/MySQL Server 5.0/bin/mysqladmin-u root-p shutdown
Replace newpassword with your new password. The second command will allow you to repeat the new password.
6. net start mysql in cmd
Unix & Linux:
1. log on to the system using root or a user running mysqld;
2. Use the kill command to end the mysqld process;
3. Use the-skip-grant-tables parameter to start MySQL Server
# Mysqld_safe-skip-grant-tables &
4. Then use the empty password to log on to MySQL as the root user; mysql-u root
5. Set a new password for root @ localhost
Mysql> update mysql. user set password = PASSWORD ('new password') where User = 'root' mysql> flush privileges; mysql> quit
6. Restart MySQL
Note that the two marked in red are "-". If the name is not executed, an error is returned. "-k ......"