1.mysql
-U USERNAME
-P
-H Mysql_server
Linux:socket
Windows:memory
2. Command categories in interactive mode
Client commands
Server-side commands
You must use the statement terminator, which is the default number
3. Relational database objects:
Table
Index
View
Constraints
Stored Procedures
Storage functions
Trigger
Cursor
User
Permissions
Transaction
4. Common commands
DDL: Database Definition language
Create,alter,drop
DML: Database Administration language
Insert,update,delete
DCL: Database Control Language
Grant,revoke
Create a database
Create DATABASE db_name;
Create DATABASE [if not EXISTS] db_name;
Deleting a database
drop database [if exists] db_name;
Create a table
CREATE TABLE Tb_name (Col1,col2,...);
View the table in the library: show tables from db_name;
View table structure: desc tb_name;
Delete tables: drop table tb_name;
Modify table: ALTER TABLE Tb_name
Modify,change,add,drop
Insert INTO Tb_name (col1,col2,...) values|value (' string ', num,...);
Update tb_name set column=value where condition;
Delete from tb_name where condition;
Select field from Tb_name where condition
*: All fields
Where: No condition indicates all rows are displayed
To create a user:
Create user ' username ' @ ' host ' identified by ' password ';
Drop user ' username ' @ ' host ';
Grant Pri1,pri2,... on Db_name.tb_name to ' username ' @ ' host ' [identified by ' Password '];
Revoke Pri1,pri2,... on Db_name.tb_name from ' username ' @ ' host ';
To view the user's authorization: Show grants for ' username ' @ ' host ';
Flush privileges;
To set a password for a user:
Mysql>set password for ' username ' @ ' host ' =password (' password ');
# mysqladmin-uusername-hhost-p password ' password '
Mysql>update user set Password=password (' Password ') where user= ' root ' and host= ' 127.0.0.1 ';