When the user installs the MySQL database for the first time, he always wants to change the initialization password of root. I do it too. I check it on Baidu every time. Here are some commonly used methods for operating the database. SQL and some Basic concepts, friends who need it can refer to it
When users install the MySQL database for the first time, they always want to change the initialization password of root. Me too, every time Baidu, the following mainly gives some common SQL and some basic conceptual things for operating databases.
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 users:
GRANT all privileges ON databasename.tablename TO ‘username'@‘host'; flush privileges;
Set and change passwords:
SET PASSWORD FOR ‘username'@‘host' = PASSWORD(‘password');
Revoke permissions:
REVOKE privilege ON databasename.tablename FROM ‘username'@‘host';
DeleteUser:
DROP USER ‘username'@‘host';
View user authorization:
SHOW grants for ‘username'@‘host';
Innodb engine provides ACID transaction support:
A (atomicity; Atomicity) means that a transaction is either fully executed or not executed;
C (Consistency; Consistency) means that the running of the transaction does not change the consistency of the data in the database;
I (Independence; Isolation) is also called isolation, Refers to a state where two or more transactions will not be executed alternately;
D (Durability) refers to the fact that after the transaction is successfully executed, the changes made will be persisted in the database and will not Rollback for no reason;
MYSQL Isolation Level:
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 results of query are the state at the beginning of the transaction.
MYSQL's locking mechanism:
The locking mechanism is that the database changes various shared resources when they are accessed concurrently in order to ensure the consistency of the database. A rule set by order.
Row-level locking
The granularity of lockingobject is very small and can easily cause deadlock, but the contention for locking resources The probability of using it 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.
The above is the detailed content of mysql5.7 method to change user initial password_Mysql. For more information, please follow other related articles on the PHP Chinese website!