Linux under MySQL Insert update delete transaction user management
1.INSERT INSERT statement Format:
INSERT into Tb_name (Field 1, Field 2, ...) Values (value 1, value 2, ...) [, (value 1, value 2, ...),...];
INSERT into table name SET field 1= value 1, field 2= value 2,...;
INSERT into table name (Field 1, Field 2,...) SELECT (field 1, Field 2,...) From table name [WHERE condition];
2.REPLACE INSERT statement Format:
REPLACE into Tb_name (Field 1, Field 2, ...) Values (value 1, value 2, ...) [, (value 1, value 2, ...),...];
REPLACE into table name SET field 1= value 1, field 2= value 2,...;
REPLACE into table name (Field 1, Field 2,...) SELECT (field 1, Field 2,...) From table name [WHERE condition];
3.DELETE Delete the contents of the table:
Delect from table name WHERE condition;
Delect from table name; #清空表但不会重置计数器
TRUNCATE table name; #清空表并重置AUTOCREMENT计数器
4.UPDATE Update the contents of the table
UPDATE table name SET field 1= ..., field 2= ... WHERE condition;
5. Lock table:
Read Lock: Shared lock
Write Lock: Exclusive lock
LOCK TABLES table name {read| WRITE};
UNLOCK TABLES
6. Business
6.1. Explicitly start the transaction:
Start TRANSACTION: Start transaction
ROLLBACK: Rolling back
Commit: Submit #注意提交后就不能回滚
6.2. No explicitly initiated transaction:
Autocommit: Can achieve automatic submission, each operation is submitted directly;
Recommendation: Explicitly use transactions, and turn off autocommit;
SET autocommit=0;
SET @ @autocommit;
6.3. Transaction Save Point
Save point: SavePoint name
Rollback to save point: ROLLBACK to name
7. Isolation Level:
Read-uncommitted: Read not submitted
Read-committed: Read Commit
Repeatable-read: Can be stressed
SERIALIZABLE: Serializable
SELECT @ @tx_isolation;
SET tx-isolation= ' read-uncommited ';
8. Create a user
CREATE USER [email protected] '% ' identified by ' Redhat ';
5. Authorized User Rights
GRANT CREATE on ' Willow '. * to ' willow ' @ '% '
GRANT INSERT on ' Willow '. * to ' willow ' @ '% '
GRANT ALTER on ' Willow '. * to ' willow ' @ '% '
GRANT SELECT on ' Willow '. * to ' willow ' @ '% '
GRANT UPDATE (age) on willow.students to [email protected] '% '; #授权用户仅字段修改权限
6. Delete a user
DROP user ' username ' @ ' host '
9. Renaming users
RENAME user old username to new user name
10. Retrieving user authorizations
REVOKE SELECT on willow.* from [email protected] '% ';
11.mysql admin password forgot to retrieve password:
Stop MySQL Service
Service Mysqld Stop
Vim/etc/init.d/mysqld
Inserting in the start statement
--skip-grant-tables
--skip-networking
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/83/CE/wKioL1d8y0qTaY-vAAHk9mVTHrc535.jpg-wh_500x0-wm_3 -wmp_4-s_1694436580.jpg "title=" 1.jpg "alt=" Wkiol1d8y0qtay-vaahk9mvthrc535.jpg-wh_50 "/>
Service Mysqld Stop
MySQL #本地连上服务器此时跳过授权直接登入
Use MySQL;
UPDATE user SET Password=password (' Redhat ') WHERE user= ' root ';
Note: You cannot modify the password directly with the SET command because the authorization has been skipped.
# set PASSWORD for ' root ' @ ' localhost ' =password (' Redhat ');
Modify its password directly by updating the authorization table, and remove the mysqld that you just added and restart the server MySQL.
Two parameters are passed when starting Mysqld_safe:
--skip-grant-tables
--skip-networking
--skip-name-resolve
This article is from the "Xavier Willow" blog, please be sure to keep this source http://willow.blog.51cto.com/6574604/1811720
Linux under MySQL Insert update delete transaction user management