In the MySQL database, how does one set a password? when you install MySQL on the machine for the first time, you can access the database anonymously or enter the database as a root without a password. If you are an administrator, you need to establish and authorize some users, which also involves setting the password. next we will discuss how to set the password:
First, we should know that password storage in the Mysql database must be encrypted using the password () function. because the user table stores passwords in encrypted form, rather than plain text. if you are not encrypted, execute the following statement in the database:
Use mysql
Insert into user (host, user, password) values
('%', 'User _ name', 'Your password ');
Flush privileges;
I believe that the results will not satisfy you. because the server compares the encrypted values, the server connection will fail. here we need to describe flush privileges; this
Command to reload the authorization table. you can also use mysqladmin-u root reload or mysqladmin-u root flush-privileges in shell.
Implement the reload authorization table.
In the MySQL environment, you can use the following statement to set the 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 used to reload the authorization table.
3. of course, you can set a password when creating a user. The grant statement will automatically encrypt the password for you.
Example:
Grant all on *. * to mailto: user_name @
Identified by "your password ";
In addition, you can use the mysqladmin program in the shell environment to set the password.
Example:
Mysqladmin-u root password "your password"