How to set a password for the user This article comes from: Ossur Author: Dream (2001-07-05 10:08:00)
When installing MySQL on the machine, you can access the database anonymously to enter the database as a root without password. In addition, if you are an administrator, you have to establish and authorize some users, this is also involved Question of the password. Let's discuss how to set your password: First we should know that the password storage in the mysql database must be encrypted with the password () function. Because in the User table, the password is stored in encryption, not as a plain text If you do not encrypt, do the following statement directly in the database: Use MySQL Insert Into User (Host, User, Password) Values ('%', 'User_name', 'Your Password'); Flush Privileges; believes that the result will not let You are satisfied. Because the server is compared to the encrypted value, the server connection must fail. It is necessary to explain Flush privileges; this command has played a reloading license table. You can also use mysqladmin -u root reloads under the shell or MySQLADMIN -U Root Flush-Privileges To achieve an overload authorization table. In the MySQL environment, you can use the following statement to set your password: 1.insert INTO USER (Host, User, Password) Values ('%', 'user_name ", Password ("Your Password"); 2.Set Password for user_name = password ("Your Password") The above two methods must be an overload authorization table. Of course you can also set your password directly when you create a user, GRANT The statement will automatically encrypt the password for you. If a grant all on *. * To user_name @% identified by "Your password"; you can also use the mysqladmin program in the shell environment to set the password such as mysqladmin -u root password "Your Password" Go and try it, no problem!