Keyboard ESC clear Command \c Cancel command
Login mysql-ucountname-p enter cmd command invalid in operating system environment variable register MySQL
Show all databases show databases
Display table use dbname;show tables;
Display table structure desc tname;
Register MySQL account grant all on dbname.* to "countname" @ "localhost" identified by "PWD";
Create DATABASE dbName;
Delete database drop databases dbName;
Backing up the database Mysqldump-uroot-p dbname>d:/123.sql;
Import mysql-uroot-p dbname>d:/123.sql;
Use DbName; SOURCE D:/123.sql;
MySQL state information status;
CREATE TABLE Student
(Id int unsigned primary key auto_increment, primary key auto-increment
No Int (3) Zerofill insertion 3 loser 003
Sex,tinyint default 0)
Select if (Sex, "Boy", "schoolgirl") from student
Select Concat ("name": SName, "gender", sex) from student
SELECT * FROM Studnet limit 2 take the first two
Select Sname from student order by birthday LITMI 1, 1; Find the second-oldest student
ALTER TABLE student modify name character set UTF8;
Show character set;
Show collation; character Set validation rules
Show CREATE TABLE Student
The variables in MySQL do not have to be declared beforehand, use "@ variable name" when using it.
First usage: Set @num = 1; or set @num: = 1; To use variables to save the data, use the @num variable directly
Second usage: select @num: = 1; or select @num: = field name from table name where ...
Note the above two assignment symbols, which can be "=" or ": =" when using set, but must use ": = Assignment" When using Select
To set a global variable, there are two different ways:
Set global var_name = value; Note: Global cannot be omitted here. According to the manual, the set command sets the variable without specifying global, session, or local, using the session by default
SET @ @global. Var_name = value; Ditto
To see a global variable, there are two different ways:
SELECT @ @global. var_name;ame = value; Ditto
MySQL basic commands