I. Linux Article 1. stop mysql service: service mysql stop; 2. Modify the my. cnf file and find/-name my. cnf. The file contains
[Mysqld] datadir =/var/lib/mysqlsocket =/var/lib/mysql. sockuser = mysql
This is the file we are looking for. Add skip-grant-tables under user-mysql, save the file, and exit 3, mysqld restart; 4, service mysql start.5. Enter mysql to enter mysql! Ii. Windows 1. First, stop the running MySQL process> net stop mysql. If it is not loaded as a service, you can directly close it in the Process Manager or service. 2. Start MySQL in safe mode to enter the mysql directory and run it under the command line> d:> cd xampp/mysql/bin> mysqld.exe -- after the skip-grant-tables3, you can enter MySQL without a password> mysql-u root-p prompt to enter the password directly press Enter. 4. Change Password> use mysql> update user set password = Password ('new password') where User = 'root';> flush privileges; 5. Start MySQL and close all MySQL processes in Task Manager. Run the following command to start MySQL.> Net start mysqlmysqladmin-u root-p shutdown