Home  >  Article  >  Database  >  How to change user initial password in mysql5.7

How to change user initial password in mysql5.7

小云云
小云云Original
2018-01-17 09:27:441423browse

When users install the MySQL database for the first time, they always want to change the root initialization password. The following mainly gives some common SQL and some basic conceptual things for operating the database. I hope it can help everyone.

Modify the user's initialization password:

SET PASSWORD = PASSWORD(‘your new password');
ALTER USER ‘root'@‘localhost' PASSWORD EXPIRE NEVER;
flush privileges;

Create a new user:

CREATE USER ‘username'@‘host' IDENTIFIED BY ‘password';

Grant permissions to the user:

GRANT all privileges ON databasename.tablename TO ‘username'@‘host';
flush privileges;

Set and change password:

SET PASSWORD FOR ‘username'@‘host' = PASSWORD(‘password');

Revoke permissions:

REVOKE privilege ON databasename.tablename FROM ‘username'@‘host';

Delete users:

DROP USER ‘username'@‘host';

View user authorization:

SHOW grants for ‘username'@‘host';

The Innodb engine provides support for ACID transactions:

  • A (Atomicity) refers to a transaction that is either fully executed or not executed;

  • C (Consistency) refers to the execution of a transaction and the Does not change the consistency of the data in the database;

  • I (independence; Isolation) is also called isolation, which refers to a state in which two or more transactions will not be executed alternately;

  • D (Durability; Durability) means that after the transaction is successfully executed, the changes will be persisted in the database and will not be rolled back for no reason;

MYSQL isolation level:

How to change user initial password in mysql5.7

Dirty read: Allows reading of uncommitted dirty data.

Non-repeatable reading: Some records are read at point T1. When these records are re-read at point T2, these records may have been changed or disappeared.
Phantom reading: solves the problem of non-repeated reading and ensures that in the same transaction, the query results are the state at the beginning of the transaction.

MYSQL's locking mechanism:

The locking mechanism is a rule set by the database to ensure the consistency of the database and to order various shared resources when they are accessed concurrently.

  • Row-level locking

  • The granularity of the locked object is very small, which can easily cause deadlock, but the probability of lock resource contention is also minimal.

  • Page-level locking

  • is between row-level locking and table-level locking.

  • Table-level locking

Maximum granularity locking mechanism. Deadlock is less likely to occur, but resource competition is more likely to occur.

Table-level locking is mainly used in some non-transactional storage engines such as MyISAM, Memory, and CSV. Row-level locking is mainly used in Innodb and NDBCluster storage engines. Page-level locking is mainly used in BerkeleyDB.

Related recommendations:

How to change the password in MySQL5.7.18

Detailed explanation of examples of changing passwords and access restrictions in MySQL

What to do if you forget your MySQL password in Linux? Steps to change password from command line

The above is the detailed content of How to change user initial password in mysql5.7. 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