Linux system:
# /etc/init.d/mysql stop
#mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
#mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit;
#mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit;
Windows system
:
1. Log in to the system with the system administrator.
2. Stop the MySQL service.
3. Enter the command window, and then enter the MySQL installation directory, such as my installation directory is c:\mysql, enter C:\mysql\bin
4. Start MySQL without permission check
c:\mysql\bin>mysqld-nt ––skip-grant-tables 或:c:\mysql\bin>mysqld ––skip-grant-tables
执行:mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit ;
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit ;