How to modify the initial password of a user in mysql5.7

How to modify the initial password of a user in mysql5.7

When users install MySQL database for the first time, they always want to change the initial root password. I do the same and always search on Baidu. Here are some commonly used SQL for operating database and some basic concepts.

Modify the user's initial 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;

To set and change your password:

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

Revoke permissions:

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

To delete a user:

DROP USER 'username'@'host';

View the user's authorization:

SHOW grants for 'username'@'host';

The Innodb engine provides support for ACID transactions:

  • A (Atomicity) means that a transaction is either fully executed or not executed;
  • C (Consistency) means that the execution of a transaction does not change the consistency of the data in the database;
  • I (Independence; Isolation) is also called isolation, which refers to the state in which two or more transactions are not executed alternately;
  • D (Durability) means that after a transaction is successfully executed, the changes made will be persisted in the database and will not be rolled back for no reason;

MYSQL isolation level:

這里寫圖片描述 

Dirty read: allows reading of uncommitted dirty data.

Non-repeatable read: Some records are read at point T1. When these records are read again at point T2, these records may have been changed or disappeared.
Phantom read: It solves the problem of non-repeatable reads and ensures that the query results in the same transaction are the same as when the transaction started.

MYSQL locking mechanism:

The locking mechanism is a rule set by the database to ensure the consistency of the database and make various shared resources orderly when being accessed concurrently.

  • Row-level locking
  • The granularity of the locked object is very small, which can easily cause deadlock, but the probability of locking resource contention is also minimal.
  • Page-level locking
  • Between row-level locking and table-level locking.
  • Table-level locking

The most granular locking mechanism. Deadlock is not likely to occur, but the probability of resource competition is higher.

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.

The above is the method of changing the user's initial password in MySQL 5.7 that I introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • What to do if you forget the initial password when installing MySQL on Mac
  • How to install and modify the initial password of mysql5.7.18 under Centos7.3
  • What to do if you forget the initial password of MySQL on MAC
  • What to do if you forget the initial password of MySQL on MAC
  • A simple and effective solution to forget the initial password when installing MySQL

<<:  More than 100 lines of code to implement react drag hooks

>>:  Linux kernel device driver system call notes

Recommend

How to install mysql via yum on centos7

1. Check whether MySQL is installed yum list inst...

How to adapt CSS to iPhone full screen

1. Media query method /*iPhone X adaptation*/ @me...

Detailed troubleshooting of docker.service startup errors

Execute the following command to report an error ...

Distributed monitoring system Zabbix uses SNMP and JMX channels to collect data

In the previous article, we learned about the pas...

How to use CSS to write different styles according to sub-elements

The effect we need to achieve: What is needed The...

VMware kali virtual machine environment configuration method

1|0 Compile the kernel (1) Run the uname -r comma...

Docker image creation Dockerfile and commit operations

Build the image There are two main ways to build ...

Detailed example of concatenating multiple fields in mysql

The MySQL query result row field splicing can be ...

Summary of MySQL lock related knowledge

Locks in MySQL Locks are a means to resolve resou...

HTML+CSS to achieve responsive card hover effect

Table of contents accomplish: Summarize: Not much...

Solution to the problem that Centos8 cannot install docker

Problem [root@zh ~]# [root@zh ~]# [root@zh ~]# yu...

Monitor the size change of a DOM element through iframe

A common problem encountered during the developme...