1. view the port
Netstat-
2. log on to the MySQL server
Mysql-u root-P mysql-hlocahost-u root-P
3. Select a database
Show Databases
4. Set character sets
Set names 'gbk ';
5. query tables in the database
Show tables;
6. Set character sets
Set names 'gbk ';
7.
Create a table
Create tabletest (
TID int (10) Not null,
Tname varchar (100) notnull,
Tdate datetime not null default '2017-00-00 ',
Primary Key (TID ));
8. view the table structure
Desc test;
9. add columns
Alter table testadd (Tage int (3 ));
10. Modify the column Default Value
Alter table test altertag set default '0 ';
11. delete default values
Alter table test altertag drop default;
12. Delete Columns
Alter table test dropcolumn tag;
13. insert data
Insert into test (TID, tname, tdate) value (1, 'ymm', '2017-11-04 ');
14. delete a table
Drop table test;
15. Modify the table name
Alter tabletest rename test1;
16. display the database version
Select version ();
17. Refresh the database
Flush privileges;
18. query the current time
Select current_date;
19. Write the queried data to a file.
Select * From test1into OUTFILE "F:/test.txt" fields terminated ",";
20. view the database status
Status;
21. view all codes for basic MySQL operations
Show variables like 'character _ SET _ % ';
22. Set the primary key to auto-Increment
TID int (10) Not null
Auto_increment, // when setting the primary key
Alter table auto auto_increment = (10 );