I. Summary of MySQL password change methods
The first thing to note is: Generally, you need to have the root permission in MySQL to change the MySQL password. In this way, you cannot change the password unless you ask the Administrator to help you modify the password.
Method 1
Using phpMyAdmin (a graphical MySQL database management tool) is the simplest. You can directly use SQL statements to modify the user table of the MySQL database, but do not forget to use the password function to insert the user using the INSERT command, modify the user's use of the update command and delete the use of the DELETE command. This section describes the user field of a data table.
Method 2
Use mysqladmin. Input
Mysqladmin-u root-P oldpassword newpasswd
After executing this command, you need to enter the original root password, so that the root password will be changed to newpasswd. Similarly, change the root in the command to your username, and you can change your password. Of course, if your mysqladmin cannot connect to MySQL server, or you cannot execute mysqladmin, this method is invalid, and mysqladmin cannot clear the password.
The following methods are used at the MySQL prompt and must have the root permission of MySQL:
Method 3
Mysql> insert into mysql. User (host, user, password) values ('%', 'system', password ('manager '));
Mysql> flush privileges
Specifically, this is to add a user with the username system and Password Manager. Be sure to use the password function, and then use flush privileges for confirmation.
Method 4
Similar to method Sany, but the replace statement is used.
Mysql> replace into mysql. User (host, user, password)
Values ('%', 'system', password ('manager '));
Mysql> flush privileges
Method 5
Use the SET Password statement
Mysql> set password for system @ "%" = PASSWORD ('manager ');
You must also use the password () function, but do not need to use flush privileges for confirmation. % Indicates any host name
Method 6
Use the grant... identified by statement to grant permissions.
Mysql> grant usage on *. * to system @ "%" identified by 'manager ';
Here, the password () function is unnecessary and you do not need to use flush privileges for confirmation.
Note: The password () function is used to encrypt passwords and automatically interpret them in MySQL.
Ii. How to Set access restrictions in MySQL
We use two methods to set users.
Go to the MySQL execution directory (usually C: mysqlin ). Enter mysqld-mongoware.exe and MySQL -- user = root mysql. Otherwise, you cannot add new users. Go to the mysql> prompt to perform the operation.
Suppose we want to create a super user with the username system and user password manager.
Method 1
Use the grant command for authorization. The input code is as follows:
Mysql> grant all privileges on *. * to system @ localhost identified by 'manager' with grant option;
Display: Query OK, 0 rows affected (0.38 Sec)
Method 2
Set each permission of a user:
Mysql> insert into user values ('localhost ','
System ', password ('manager'), 'y ','
Y', 'y ','
Y', 'y', 'y ');
For MySQL 3.22.34, there are 14 "Y" in total. The corresponding permissions are as follows (sorted by field ):
Permission table column name explanation Scope
Select select_priv the select permission table is required only when a table is actually retrieved.
Insert insert_priv allows you to Insert a new row into an existing table.
Update update_priv allows you to use the new value to update the columns in the row of an existing table.
Delete delete_priv allows you to delete row tables that meet the conditions.
Create create_priv allows you to create new databases and table databases, tables, or indexes.
Drop drop_priv discard (delete) existing database and table database or table
Reload reload_priv allows you to tell the server to read the authorization table again. Server Management
Shutdown shutdown_priv may be abused (by terminating the server and rejecting other user services) Server Management
Process process_priv allows you to view the common text of the currently executed query, including setting or changing the password query server management.
File file_priv permission can be abused to read any readable files from the server to the database table server for File Access
Grant grant_priv allows you to grant your own permissions to other user databases or tables.
References references_priv allows you to open and close the record file database or table
Index index_priv allows you to create or discard (delete) index tables.
Alter alter_priv allows you to change the table, which can be used to overturn the permission system table by renaming the table.
If you only have select, insert, update, and delete permissions when creating a user, you can only perform operations on the existing table of a database.
Next we can create the database we want to use. We can directly enter it. For example, we want to create a database named xinxiku. The following code is available:
Mysql> Create Database xinxiku;
Display:
Query OK, 1 row affected (0.00 Sec)