Unixlinux 1: First stop mysqld, it is best to kill killallmysqld 2: Start mysql, but skip the permission table usrlocalmysqlbinmysqld_safe -- skip-grant-tables 3: Go to mysql, and change the password usrlocalmysqlbinmysql-urootmysqlusemysql; mysqlupd
Unix linux 1: First stop mysqld. It is best to killall mysqld 2: Start mysql, however, you must skip the permission table/usr/local/mysql/bin/mysqld_safe -- skip-grant-tables. Third, go to mysql, and change the password/usr/local/mysql/bin/mysql-u root mysqluse mysql; mysqlupd
Unix & linux
First, stop mysqld and kill it all.
Killall mysqld
Second, start mysql, but skip the permission table.
/Usr/local/mysql/bin/mysqld_safe -- skip-grant-tables &
Third, go to mysql and change the password.
/Usr/local/mysql/bin/mysql-u root
Mysql> use mysql;
Mysql> update user set password = password ("new_pass") where user = "root ";
Mysql> flush privileges;
Mysql> \ q
4. Restart mysql and enter normally.
Windows
First, go to the command line in the Windows window and stop the mysql service: net stop mysql
2. Go to the mysql installation directory and go to the bin directory.
Mysqld-nt.exe -- skip-grant-tables
Third, go to the mysql installation directory in another window and change the password:
Execute mysql.exe
> Use mysql;
> Update set user password = password ("new_pass") where user = "root ";
> Flush privileges;
> \ Q
4. End the mysqld-nt process and restart mysql.
In windows, if the above method cannot be solved, you can add the following line in the [MySQLd] configuration section of my. ini:
Skip-grant-tables
Save it, restart mysql, and use mysql-uroot to access the database as the root user.