One, Linux 1, stop MySQL services: service MySQL stop;2, modify my.cnf file, can be found through the Find/-name my.cnf file, the content contains
[Mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql
That is the file we are looking for, added under User-mysql: Skip-grant-tables, save and exit 3,mysqld restart;4,service mysql start.5, enter MySQL to enter mysql! Second, Windows 1, first stop the running MySQL process >net stop MySQL is not loaded as a service and can be shut down directly in the Process Manager or service. 2. Start MySQL in Safe mode to enter the MySQL directory run >D:>CD xampp/mysql/bin >mysqld.exe--skip-grant-tables3 on the command line. After completion, you can use the password to enter the MySQL >mysql-u root-p prompt to enter the password when the direct carriage. 4. Change Password >use mysql>update user set Password=password (' New password ') where user= ' root '; >flush privileges;5, Start the MySQL service to close all MySQL processes in Task Manager and start with the following command. >net start mysqlmysqladmin-u root-p shutdown