How to change the password when the mysql password is forgotten (Linuxamp; amp; Windows)
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