Category Archives: Mac

怎么打开/查看MySQL的SQL记录?

我们在开发的时候经常经常遇到在程序中增加调试语句很麻烦的情况,这时候难免会想如果Mysql能看到我们执行了什么SQL语句就好了。

实际上MySQL是有这个功能的,在MySQL 5.1的时候我们就可以通过mysqld的-l参数来启动mysql来记录查询日志。

但是现在-l参数自5.1.12之后已经不推荐使用了,改为–general_log

As of MySQL 5.1.12, as an alternative to –log or -l, use –general_log[={0|1}] to specify the initial general query log state. In this case, the default general query log file name is used. With no argument or an argument of 1, –general_log enables the log. With an argument of 0, this option disables the log.

 

–general_log 打开后日志默认会输出到你的data目录下,默认文件名是 hostname.log。hostname是你的机器名,在windows上貌似是localhost或者其他什么奇怪的名字吧。

 

如果服务器已经启动或者不是直接用mysqld启动服务器的怎么办呢?(运行时开关General Log)

执行下面两个SQL就可以开关日志

打开日志

SET GLOBAL general_log = 'ON';

关闭日志

SET GLOBAL general_log = 'OFF';

 

配置文件可以设置General Log的开关吗?

在配置文件中[mysqld]段增加下面一行

general_log = 1

如果需要指定日志文件路径

general_log_file = 文件路径

Read: 5807

修复zsh svn1.7 自动完成的问题

更新svn(subversion)到1.7后 zsh 的svn自动完成就傻X了。

错误: _arguments:comparguments:312: invalid argument: [–cl]:arg:

修改方法

打开文件:/usr/share/zsh/4.3.11/functions/_subversion

找到35行左右

${=${${${(M)${(f)”$(LC_ALL=C _call_program options svn help $cmd)”#(*Valid options:|(#e))}:#* :*}%% #:*}/ (arg|ARG)/:arg:}/(#b)-([[:alpha:]]) \[–([a-z-]##)\](:arg:)#/(–$match[2])-    $match[1]$match[3] (-$match[1])–$match[2]$match[3]}

改为

${=${${${(M)${(f)”$(LC_ALL=C _call_program options svn help $cmd)”#(*Valid options:|(#e))}:#* :*}%% #:*}/ (arg|ARG)/:arg:}/(#b)(-##)([[:alpha:]]##) \[–([a-z-]##)\](:arg:)#/(-    -$match[3])$match[1]$match[2]$match[4] ($match[1]$match[2])–$match[3]$match[4]}

 

参考资料:

http://www.zsh.org/mla/workers/2011/msg01448.html

Read: 196

Deploy PHP Development Environment on Macintosh OS

— PREPARE —

1. Install MacPort

2. sudo port install pcre jpeg libpng mcrypt ImageMagick

3. Download PHP, Nginx, Redis, MySQL

 

— Compile & Install —

1. MySQL dmg

2. Nginx

./configure –prefix=/opt/nginx

make

make install

3. Redis

make PREFIX=/opt/redis install

4. PHP

./configure  –prefix=/opt/php53 –with-config-file-path=/opt/php –with-mysql=mysqlnd –with-pdo-mysql=mysqlnd –with-iconv=/opt/local –with-xsl –enable-xml –with-libxml-dir –disable-rpath –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-libexpat-dir=/usr/lib –with-curl –with-curlwrappers –enable-mbregex –enable-ftp –with-gd –enable-zip –enable-sockets –enable-soap –enable-mbstring=all –with-mcrypt=/opt/local –enable-gd-native-ttf –with-freetype-dir=/opt/local –with-zlib –without-pdo-sqlite –enable-fpm –with-snmp –without-sqlite –without-pdo-sqlite –with-openssl –with-jpeg-dir=/opt/local –with-png-dir=/opt/local –with-xpm-dir=/opt/local

make

make install

sudo pecl install imagick

// prefix = /opt/local

 

— Configure —

 

…..

Read: 1111