Http://wenku.baidu.com/view/3f7319a4f524ccbff1218468.html
1. Install
Http://www.cnblogs.com/276815076/archive/2012/04/01/2428364.html
Installation Package
Sudo apt-get install mysql-server
Set root Password
Mysqladmin-u root password 'abc123'-p
2. configure the mysql to accept connection from outside.
In/etc/mysql/my. cnf change this:
Bind-address = 127.0.0.1
To
Bind-address = 0.0.0.0
3. configure mysql to accept root connection from remote host
Grant all privileges on *. * to 'root' @ '%' identified by 'passwd' with grant option;
This method is transferred from http://www.cnblogs.com/wliang22/archive/2009/11/13/1602423.html
4. Create a user
Create user abc;
2. Create/select a database
Create database dev;
Show databases;
Use dev;
Drop database dev;
Delete a database.
3. Display/create a table
Show tables;
Create table pet (name varchar (20), owner varchar (20), species varchar (20), sex char (1), birth date, death date );
Describe pet;
+ --------- + ------------- + ------ + ----- + --------- + ------- +
| Field | Type | Null | Key | Default | Extra |
+ --------- + ------------- + ------ + ----- + --------- + ------- +
| Name | varchar (20) | YES | NULL |
| Owner | varchar (20) | YES | NULL |
| Species | varchar (20) | YES | NULL |
| Sex | char (1) | YES | NULL |
| Birth | date | YES | NULL |
| Death | date | YES | NULL |
+ --------- + ------------- + ------ + ----- + --------- + ------- +
Drop table pet;
Delete table
4. Import table data from a file
5. data input and reading
Insert into pet values ('puffball', 'diane ', 'hamster', 'F', '2017-02-01', NULL );
Select * from pet;
The select format is
Select what_to_select
From which_table
Where conditions_to_satisfy
SelectDistinctOwner from pet;
Duplicate items are not displayed.
Select name, birth from petOrderBirth;
Sort
6. Delete table content
Delete from pet;
7. Update table records
Update pet set death = '2017-09-08 'where name = 'puffball ';