登录:[mysql@localhost~]$ sudo bin/mysql --port=3306 -u root -p -S /tmp/mysql.sock
install Doct include: windows
---------------------------------------
目录 目录内容
-----------------------------------------
bin 客户端程序和mysql服务器
data 日志文件 数据库
docs 文档
examples 示例程序和脚本
nclude 包含头文件
lib 库
scripts 实用工具脚本
share 错误消息文件
==========================
安装后将会在以下系统目录产生文件 linux
---------------------------------------
/usr/bin 客户端程序和脚本
/usr/sbin mysql服务器
/var/lib/mysql 日志文件 数据库
/usr/share/doc/packages 文档
/usr/incude/mysql 包含头文件
/usr/lib/mysql 库
/usr/share/mysql 错误消息和字符文件
/usr/share/sql-bench 基准程序
--------------------------------
=======================操作==============================
1. 创建/删除数据库:create/drop database xxx;
2. 创建/删除表: create/drop table xxx [valuse ()];
3. 添加索引等: create index on xxx (yyy);
4. 复制表: create table yyy select [*,y,z ]from xxx [where gggg]; 此时表的结构类似 建立空表 在 where 中设置一个不存在的关系
create table like xxx;
5. 修改表:
添加新字段 alter table xxx add xyz hfbi ;
修改已存在的字段的名字和类型: alter table change xxx yyy fdhjj;
删除字段: alter table xxx drop yhn;
重命名: alter table xxx rename to yyy; rename table xxx to yyy;
6. 使用数据:
插入记录:insert into xxx values ();
更新记录:update xxx set hgk=gjhau [where nuhgkji];
删除记录:delect from xxx where jkhaurh; 当省略 where 时删除所有记录
内建函数:select sum() avg() now() from xxx [where jhak]; 好像不能和字段在一块查询?
别名 as 限制 limit 排序 orer by [asc desc] 分组 group by
使用变量: select @dfkb:=某操作结果 使用: select @dfkb; select fhu from xxx where bflb=@dfkb;
复制记录:insert into xxx [()] select jg,gh from yyy [where jha];
批量数据:load data local infile '/home/lvshang/....' into table xxx fields terminated by ',' lines terminated by '\n\;
导出记录:select gi,jghe from xxx [where fhfnk ] into outfile '/home/lvshang/yyyy' fields terminsted by ',' enclosed by
'"' lines terminated by '\t\n';
1.修改表的相关内容的知识
1.1 alter table biao1 add clomname xxx; 追加新的字段
1.2 alter table biao1 drop clomname; 删除原有的字段
1.3 alter table biao1 change clomname clomname_new xxx ; 改编字段的相关内容
1.4 alter tbale biao1 modify clomname xxxx; 只是修改字段的类型等内容,不改变字段的名字
1.5 alter table biao1 rename to name_new; rename table biao1 to name_new; 均为重命名表明
1.6 alter table biao1 alter clomname set default xx/drop default 为一个字段设置或删除默认值xx (数字),不常用
1.7 alter ignore table biao1 change clomname xxx unique; 将表的clomname 字段设置为不允许重复的出现。注意前面的 IGNORE
1.8 alter table biao1 type= xxx; 将表的类型改为 xxx .
1.9 alter table biao1 add fulltext index xxx; alter table biao1 drop index xxx; 增加/删除索引
2. 批量添加本地文件:
load data local infile '/usr/lvshang/biaox' into table biaoy fields terminated by ',' lines terminated by '\n';