Archive for 08月, 2009

Mysql实用小技巧

1. 控制台中运行sql,在最后加\G可以将但到的信息,分行展示.
例如:
mysql> select id,name from workitems limit 2 \G;
*************************** 1. row ***************************
id: 223255
name: 提供获取指定用户项目列表的API
*************************** 2. row ***************************
id: 223256
name: 提供获取指定用户项目列表的API
2 rows in set (0.00 sec)
2. 在where子句在锁嵌套count()
错误做法:select * from user_num where count(user)>=2 group by user;
正确做法:select * from user_num group by user HAVING count(user)>=2 ;
3. 如何解决mysqlbinlog: unknown variable ‘default-character-set=utf8′的错误。
加入 –no_defaults 参数
如: /usr/bin/mysqlbinlog –no-defaults ./log.000043 [...]


MC Inside