MySQL under Windows
(for administrators or users with global permissions to reset another user's password)
Enter command line mode
The code is as follows |
Copy Code |
Mysql-u Root MySQL mysql> UPDATE user SET Password=password ("New password") WHERE user= ' name '; mysql> FLUSH privileges; Mysql> QUIT |
Method Two:
(Apply ditto, just different method)
The code is as follows |
Copy Code |
Mysql-u Root MySQL Mysql> SET PASSWORD for Name=password (' New PASSWORD '); Mysql> QUIT |
(These two methods I am not commonly used, if the administrator, I will use other tools such as phpMyAdmin or mysql-front to manage user rights, more intuitive and convenient)
Quick Summary
The code is as follows |
Copy Code |
A../mysqladmin-u root-p OldPassword newpasswd (remember this command is in the/usr/local/mysql/bin in the external command) B. SET PASSWORD for Root=password (' New PASSWORD ') (in this way after logging in to the database) C. UPDATE user SET Password=password ("New password") WHERE user= ' root '; (This way after logging in to the database) |
MySQL in Linux
MySQL how to set the root password method one:
The simplest way is to install MySQL after the system prompts the method. Use Mysqladmin to complete.
The code is as follows |
Copy Code |
shell> mysqladmin-u root password "newpwd" shell> mysqladmin-u root-h host_name password "newpwd" password |
The following double quotes are not required, but quotation marks are required if the password contains spaces or some special symbols. Method MySQL How to set the root password two: Use the MySQL inside the Set password command to complete, note must use the password () function to encrypt the set of this newpwd, otherwise directly = ' newpwd ' will not take effect. However, if you use the method to set the password with mysqladmin password or grant, you do not need to use the password () function, because they have automatically called the function.
The code is as follows |
Copy Code |
shell> Mysql-u Root mysql> SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' newpwd ');
mysql> SET PASSWORD for ' root ' @ ' host_name ' = PASSWORD (' newpwd '); |
MySQL how to set the root password method three:
Set the password directly through the Update user table
The code is as follows |
Copy Code |
shell> Mysql-u Root mysql> UPDATE mysql.user SET Password = Password (' newpwd ') -> WHERE User = ' root '; mysql> FLUSH privileges; |
If you forget the MySQL root password you can take the following steps to reset
1. Kill all MySQL Processes
2. Use--skip-grant-tables parameters to start MySQL
The code is as follows |
Copy Code |
Shell> Mysqld_safe--skip-grant-tables & |
The last must kill skill:
The code is as follows |
Copy Code |
mysqladmin-u root "Old password" "New password" |
Solution: The above has name, please use your username to replace. There is a new password please enter the password you want to set.