Method 1: the simplest method is the method prompted by the system after mysql is installed. Use mysqladmin. Double quotes behind the shellmysqladmin-urootpasswordnewpwdshellmysqladmin-uroot-hhost_namepasswordnewpwdpassword are not mandatory, but if the password contains null or special
Method 1: the simplest method is the method prompted by the system after mysql is installed. Use mysqladmin. Shell mysqladmin-u root password newpwd shell mysqladmin-u root-h host_name password newpwd password is not a required double quotation mark, but if the password contains null or some special
Method 1: the simplest method is the method prompted by the system after mysql is installed. Use mysqladmin.
Shell> mysqladmin-u root password "newpwd"
Shell> mysqladmin-u root-h host_name password "newpwd"
The double quotation marks after the password are not mandatory. However, if the password contains spaces or some special symbols, you must use quotation marks.
Method 2: Use the set password command in mysql to complete the operation. Note that you must use the PASSWORD () function to encrypt the newpwd SET. Otherwise, directly = 'newpwd' will not take effect. However, if you use mysqladmin password or GRANT to set the PASSWORD, you do not need to use the password () function because they have automatically called this function.
Shell> mysql-u root
Mysql> set password for 'root' @ 'localhost' = PASSWORD ('newpwd ');
Mysql> set password for 'root' @ 'host _ name' = PASSWORD ('newpwd ');
Method 3: directly set the password shell> mysql-u root through the UPDATE user table
Mysql> UPDATE mysql. user SET Password = PASSWORD ('newpwd ')
-> WHERE User = 'root ';
Mysql> flush privileges;
If you forget the mysql root Password, perform the following steps to reset it:
1. Kill all mysql Processes
2. Use the -- skip-grant-tables parameter to start mysql.
Shell> mysqld_safe -- skip-grant-tables &
3. Set a new password. You can select either of the two methods.
Method 1
Shell> mysqladmin-u root flush-privileges password "newpwd"
Method 2
Mysql> UPDATE mysql. user SET Password = PASSWORD ('newpwd ')
-> WHERE User = 'root ';
Mysql> flush privileges;
4. Stop mysql server and start it in normal mode
5. OK. You can use the new password.