Owen的酒楼

--酒楼上渡过的人生--
生命太短,人生太长,但愿别喝醉了。

导航

mysql的几个要点 ZT

Posted on 2007-12-17 16:41  Hicome  阅读(198)  评论(1编辑  收藏  举报
1,支持批量更新[这个功能挺方便]
假设订单表t_order,列fid:订单编号,fname:订单名称
订单项表t_detail,列fid:项编号,forderid:订单编号,fname,订单名称,现在要设置t_detail表的fname值
sql 语句:upddate t_detail as detail left join (select fid as forderid,fname from t_order) as  order using(forderid) set detail.fname=order.fname

2,linux机器上mysql数据库文件授权:
(1)假设数据库目录 /usr/local/mysql/data/db   --------  执行脚本:chown -R mysql:mysql db
(2)进入数据库 grant all on * to mysql;

3,对某台机器开放连接权限
mysql里执行 grant all on *.* to user@ip identified by 'password';
然后更新 flush privileges

4,启动和停止mysql服务
/usr/local/mysql/bin/safe_mysql 启动
/usr/local/mysql/bin/mysqladmin shutdown -uroot -p 停止

5,重新读取数据库文件记录
flush tables

6,查看正在执行的mysql进程
show processlist

7,替换插入
replace into table values(...)

8,导入导出
导出:select * from table into outfile '/usr/local/data.txt'
导入:load data infile '/usr/local/data.txt' [replace or ignore] into table ...