After MySQL is installed on windows, the system has generated a license table and an account by default. next we will teach you how to change the default password of MySQ. After the MySQL database is installed on windows, the system has generated a license table and an account by default, you do not need to execute the mysql_install_db script on the Unix platform to generate an account and the corresponding permission table. However, if you do not use the MSI format to install MySQL, you need to manually add a new password to the root account after installation, because the root account does not enable password protection by default, if you do not re-authorize the root account password, many non-local connections will fail.
Method 1: Use the set password command. the steps for updating the PASSWORD are as follows:
C:> mysql-u rootmysql> set password for 'root' @ 'localhost' = password ('newpasswd '); mysql> set password for 'root' @ '%' = password ('newpasswd'); // optional
With the above settings, the root password is changed to newpasswd, and the root user's root password is set.
Method 2: Use mysqladmin
mysqladmin -u root password "newpass"
If the root user has set a password, use the following method:
mysqladmin -u root password oldpass "newpass"
Method 3: Use UPDATE to directly edit the user table
mysql -u root mysql> use mysql; mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root'; mysql> FLUSH PRIVILEGES;
When the root password is lost
mysqld_safe --skip-grant-tables& mysql -u root mysql mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root'; mysql> FLUSH PRIVILEGES;
In this simple way, the default password of the MySQL database is modified. after the default password is changed, you can perform more operations. I hope the content mentioned above will be helpful to you.