Detailed tutorial on setting passwords for Mysql installation-Free Edition, mysql installation Edition
Method 1: use the set password command
MySQL-u root mysql> set password for 'root' @ 'localhost' = PASSWORD ('newpass ');
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> UPDATE user SET password = PASSWORD ("new password") WHERE user = 'root'; mysql> flush privileges;
The above is a detailed tutorial on setting a password for Mysql without installation. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in time!