1,链接mysql命令:
mysql -h localhost -u root -p
在PHP里
mysql_connect('127.0.0.1','root','root');
2,查看所有库:
show databases;

3,先选一个库:
use 库名

4,查看库下面的表:
show tables;

5,建表:
create table ly(
id int auto_increment primary key,
title varchar(200),
content varchar(200),
pubtime int
)charset utf8;

6,告诉服务器你的字符集
set names gbk/utf8/...;

7,添加数据
insert into msg (id,content,pubtime) values (1,'逗你玩',13012356);

8,查询所有数据
select * from msg;

9,按id查询一行
select * from msg where id=2/1/...;

10,快速清空表

truncate 表明

查看表结构
desc 表名

增删改查

增:insert操作
所有列
指定列

注意:列与值,严格对应
数字和字符串的注意:数字不必加单引号,字符串必须加单引号


改:update操作
所有行
指定行
update user set age=15 where name='rong';
改那张表 修改 哪列    哪一行
where 必须加

删:delete
delete from 表名 where 哪一行;
要删除必删一行

查:select   查找
select * from 表名 where 哪一行;
查找  哪一列 from 表名 哪一行;