MySQL Password

xiaoxiao2021-03-06  64

Modify password and access restriction settings in mysql

In fact, it can be changed directly to PHPMYADMIN. I use 2.6.0 version.

source

Www.net.com.cn

MySQL is a real multi-user, multi-threaded SQL database server. MySQL is an implementation of a client / server structure that consists of a server daemon MySQLD and a lot of different client programs and libraries. Due to its openness and stability of its source, it is now widely used as a backend database in the openness and stability of its source code. In terms of safety considerations, each user is needed to assign access restrictions on different databases to meet different users. Here are discussed separately for your reference.

First, MySQL modified password method summary

The first thing to explain is: in general, modify the mysql password is required to have the root permissions in MySQL, so that the user cannot change the password unless the administrator helps modify.

method one

Use phpmyadmin

(Tools for graphically manage MySQL databases), this is the easiest, directly modify the USER table of the mysql database library, but don't forget to use the Password function, insert the user with the insert command, modify the user with the Update command, delete DELETE command. Detailed description of the data sheet User field later in this section.

Method Two

Use mysqladmin. enter

mysqladmin -u root -p Oldpassword newpasswd

After executing this command, you need to enter the original password of the root, so that the root password will be changed to newpasswd. Similarly, change the root in the command to your username, you can change your own password.

Of course, if your mysqladmin is connected to MySQL

Server, or you have no way to execute mysqladmin, then this method is invalid, and mysqladmin cannot empty your password.

The following method is used under the MySQL prompt, and must have mysql root privileges:

Method three

Mysql> Insert Into MySQL.user (Host, User, Password) Values

('%', 'system', password ('manager'));

Mysql> Flush Privileges

It is exactly that this is increasing a user, the user is named System, the password is Manager. Note To use the Password function, then use flush

Privileges to perform confirmation.

Method four

Same three, just use the REPLACE statement

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 Privilege to perform confirmation.

Method 6

Use the Grant ... Identified by statement to authorize.

Mysql> grant usage on *. * to system @ "%" Identified by 'Manager'

Here the password () function is unnecessary, nor does it need to use Flush Privileges to perform confirmation. Note: The PASSWORD () function function is encrypted for password, and the mysql is automatically explained in the program.

Second, the setting method of access restrictions in mysql

We use two ways to set users.

Enter into the mysql execution directory (usually C: / mysql / bin). Enter mysqld-shareware.exe, enter mysql

--user = root mysql, otherwise you cannot add new users. Go to the MySQL> prompt to operate.

Suppose we have to build a super user, the user name is system, and the user password is Manager.

method one

Use the grant command to authorize, the code entered is as follows:

Mysql> grant all privileges on *. * to system @ localhost identified by

'Manager' with grant option;

Should be displayed: Query OK, 0 ROWS Affected (0.38 SEC)

Method Two

Set each permission of the user:

MySQL> Insert Into User

VALUES ('localhost', 'system', Password ('Manager'),

'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y ',' Y ');

For the 3.22.34 version of MySQL, there are 14 "Y" here, and their corresponding permissions are as follows (in the order of field order):

Permission list name The corresponding interpretation range

SELECT SELECT_PRIV only needs SELECT permission table when retrieving from a table

INSERT INSERT_PRIV allows you to insert new rows into a table in an existing table

Update update_priv Allows you to update the list of rows in the current list of new values

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 Databases and Table Databases or Tables

Reload Reload_priv allows you to tell the server to read the authorization table server management

Shutdown ShutDown_Priv may be abused (rejected by terminating server to other user service) server management

Process process_priv allows you to view the ordinary text of the currently executed query, including setting or change password query server management

FILE FILE_PRIV permissions can be abused on the server to read any readable files to file access on the database table server

Grant Grant_priv allows you to give yourself to other user databases or tables

References References_Priv Allows you to open and close log file databases or tables

INDEX INDEX_PRIV Allows you to create or discard (delete) index tables

ALTER ALTER_PRIV allows you to change the table, can be used to overturn the permission system table by rename the table

If you create a user, only SELECT, INSERT, UPDATE, and DELETE permissions are created, allowing users to implement operations on a database existing table.

Below you can create the database we have to use, we can enter directly. For example: We want to create a database name to xinxiku, available as follows:

Mysql> Create Database Xinxiku;

Should be displayed: query ok, 1 row affed (0.00 sec)

转载请注明原文地址:https://www.9cbs.com/read-83828.html

New Post(0)