Home  >  Article  >  Database  >  Command line example operations for mysql user management and password change

Command line example operations for mysql user management and password change

巴扎黑
巴扎黑Original
2017-05-20 14:15:191981browse

MySQL Management User

MySQL user accounts and information are stored in a MySQL database named mysql. Direct access to mysql databases and tables is generally not required (you will understand this later), but sometimes direct access is required. One of the times when you need to access it directly is when you need to get a list of all user accounts. To do this, you can use the following code:

Input:

use mysql;
select user from user;

Analysis: The mysql database has a table named user, which contains all user accounts. The user table has a column called user which stores the user login name. A newly installed server may have only one user (as shown here), and a server established in the past may have many users.

Experiment with Multiple Clients The best way to experiment with changes to user accounts and permissions is to open multiple database clients (such as multiple copies of the mysql command line utility), one logged in as an administrator, Others log in as the user being tested.


Change Password

To change the user password, use the SET PASSWORD statement. The new password must be encrypted as follows:

Input:

SET PASSWORD FOR bforta = Password('n3w p@$$w0rd');

Analysis: SET PASSWORD Update user password. The new password must be passed to the Password() function for encryption.

SET PASSWORD can also be used to set your own password:

Input:

SET PASSWORD = Password('n3w p@$$w0rd');

Analysis: When the user name is not specified, SET PASSWORD updates the password of the currently logged in user .

【Related recommendations】

1. Mysql free video tutorial

2. Several points to note about mysql access control

3. MySQL character set and collation sequence tutorial

4. Introduction to MySQL character set and collation sequence

5. mysql 5.5 installation detailed graphic and text explanation

The above is the detailed content of Command line example operations for mysql user management and password change. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn