Install MySQL First:
Sudo?apt-get?install?mysql-server?mysql-client?
1. Terminal starts Mysql:/etc/init.d/mysql start;(Stop, restart.) )
2. Login Mysql:mysql-uroot-p (login with root account) and enter the password;
3. View all database names: show databases;
4. Select a database operation: use database_name;
5. View all the table names under the current database: show tables;
6. Creation of a database: create databases database_name;
7. Delete a database: Drop DB database_name;
8. Create a table: The CREATE TABLE mytest (UID bigint () NOT NULL, uname varchar (a) not null);
9. Delete a table: drop table mytest;
10.SQLInsert statement: INSERT INTO table_name (COL1,COL2) values (value1,value2);
11.SQLUpdated statement: UPDATE table_name set col1= ' value1 ', col2= ' value2 ' where where_definition;
12.SQLQuery statement: SELECT * FROM table_name where .... (the most complex statement)
13.SQLDelete statement: Delete from table_name where ...
14. Add a table structure field: Alert table table_name Add column field1 date, add column Field2 time ...
15. Delete the table structure field: Alert table table_name drop field1;
16. View the structure of the table: Show columns from table_name;
17.limit use: SELECT * FROM table_name limit 3;//only 3 rows per page
SELECT * FROM table_name limit 3,4//from the third start of the query results, four results are displayed.
This is a good place to use for paging.
18. Sort the results of the query: SELECT * FROM table_name ORDER by Field1,orderby Field2; multiple sorting
19. Exit Mysql:exit
Common commands for MySQL under Ubuntu