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 MLSQL Stack makes stream debugging easier

Preface A classmate is investigating MLSQL Stack&...

How to compile the Linux kernel

1. Download the required kernel version 2. Upload...

How to add double quotes in HTML title

<a href="https://www.jb51.net/" titl...

Detailed tutorial on installing JDK1.8 on Linux

1. Cleaning before installation rpm -qa | grep jd...

Practical record of optimizing MySQL tables with tens of millions of data

Preface Let me explain here first. Many people on...

The difference between JS pre-parsing and variable promotion in web interview

Table of contents What is pre-analysis? The diffe...

15-minute parallel artifact GNU Parallel Getting Started Guide

GNU Parallel is a shell tool for executing comput...

Detailed installation and uninstallation tutorial for MySQL 8.0.12

1. Installation steps for MySQL 8.0.12 version. 1...

Detailed steps to install JDK and Tomcat in Linux environment

Table of contents 1. Install JDK Manual Installat...

Detailed explanation of MySQL EXPLAIN output columns

1. Introduction The EXPLAIN statement provides in...

Introduction to fork in multithreading under Linux

Table of contents Question: Case (1) fork before ...

mysql5.7.17 installation and configuration example on win2008R2 64-bit system

123WORDPRESS.COM has explained to you the install...