http://wenku.baidu.com/view/3f7319a4f524ccbff1218468.html
1. 安裝
http://www.cnblogs.com/276815076/archive/2012/04/01/2428364.html
安裝包
sudo apt-get install mysql-server
設定root密碼
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;
這個方法轉自http://www.cnblogs.com/wliang22/archive/2009/11/13/1602423.html
4. 建立使用者
create user abc;
2. 建立/選擇資料庫
create database dev;
show databases;
use dev;
drop database dev;
刪除資料庫。
3. 顯示/建立表
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;
刪除表
4. 從檔案中匯入表的資料
5. 資料的輸入和讀取
insert into pet values('Puffball', 'Diane', 'hamster', 'f', '1993-02-01', NULL);
select * from pet;
select 的格式是
select what_to_select
from which_table
where conditions_to_satisfy
select distinct owner from pet;
不顯示重複的。
select name,birth from pet order by birth;
排序
6. 刪除表的內容
delete from pet;
7. 更新表的記錄
update pet set death='3098-09-08' where name='Puffball';