Archive for January, 2009

Get to MySQL data directory on Ubuntu

I’ve been asked about this and realized that it may not be obvious to people who are more familiar with Windows than with Ubuntu. So here is a tip.

When learning MySQL on Ubuntu, it is helpful to be able to get to MySQL’s data directory and observe file creation and modification while you are performing database and table creation and modification, index creation and modification, etc. You can find out MySQL’s data directory by running:

show variables like ‘datadir’;

Suppose your datadir is /var/lib/mysql. And suppose you have a database called test. After opening a terminal window and type:

cd /var/lib/mysql/test/

You will likely receive an error like below:
bash: cd: /var/lib/mysql/test/: Permission denied

Now if you try the command below, as it seems logical on Ubuntu

sudo cd /var/lib/mysql/test/

You will likely get this message:

sudo: cd: command not found

A quick way to get around it and run with root privilege, is through

sudo -i

You will then be able to get to MySQL data directory without any problems. Hope this helps somebody out there trying to learn.

Comments

2009牛年看春晚小记

亲爱的读者朋友们,牛年快乐!

这两天都和老婆忙活着,张罗一些年货和年夜饭的事儿。前两天在中国城花27刀买了个蒸锅,老婆做了馒头(我们鲁南家乡话叫馍馍)。她做得挺不错。今天我们再接再厉,做了一整桌的清蒸面食过年:素蒸饺,馍馍,芹菜猪肉蒸饺,素包子。再加上凉拌黄瓜花生米儿和茶叶蛋,也算丰盛。我拿出了几年前买的红星二锅头小酌一下,自斟自饮。我还买了一些蒜苗,明天自己胡乱炒个蒜苗猪肉吃吃。蒜苗这个东西,这十几年来吃的次数不会超过五次。

1995年来美国后,我就一直没看过春晚,到今年已经有14个春秋了。由于种种原因,我自来美国后就没有机会在中国过年。现在儿子都上四年级了,虽然每个春节都会一起庆祝,但觉得年还是要在中国过才能感受到那个气氛。虽然跟儿子谈过春晚,这个根在大陆的,全家齐聚看电视吃年夜饭的共同情结,但百闻不如一见。看奥运后知道了怎样在网上看中国电视,所以几个星期前我就打算和儿子一起看今年的春晚。我用的是TV Ants,效果还不错。

看春晚

记一下片段和个人感想。

  • 还别说,看春晚还真能调动气氛,真觉得有年味儿。总起来说我的感觉还是挺正面的,虽然我没看全,看得时候也是有一搭没一搭的,没死盯着电脑,生怕错过一个细节。我是从那四个农民歌手唱歌时开始看的,大红大紫的周董我没看着。我不算是周董的粉丝,但我喜欢他的一些歌,觉得他是个好孩子。
  • 儿子、老婆和我一起看。小家伙趴在电脑前看,好像津津有味的样子。他喜欢那个台湾魔术师。我和老婆在厨房边做饭边看。老婆喜欢那个爱尔兰舞蹈。我说他们这个挺好,是很有效的民间外交。
  • 还是感觉得到那种硬让你感动的牵强台词和肉麻氛围,不过比十几年前好多了,毕竟那么久的行事和思维方式不是一夜之间就应该强行变化的。从另一个角度来看,十几亿人的节目,众口难调,更何况,从我个人的理解来看,关于春晚的主导评论,不一定就代表着大部分人的观点,因为中国的主要人口分布在农村和小城镇,而他们在网络和媒体上的声音应当还算弱小。嗓门儿大并不意味着有道理。
  • 看完那个在亚丁湾护航的海军官兵的新年贺词,觉得不错。完了那个说子弟兵的小品就没有太注意,感觉可能有点肉麻,就没细看。那个奥运义工的小品总体不错,但还是稍感牵强。毛阿敏唱得挺好的。其他的歌曲也不错。

    另外,太多人我都不认识。和冯巩搭档的那个演在外留过学的女士我就不知道是谁。和成龙一起演唱的那三位我一个都不认识。女主持我是一个都不认识。男主持我知道朱军,因为在我买的西游记光碟里,看到他的西游记剧组访谈节目,好像叫艺术人生。白岩松我知道,因为我欣赏他的一些文章,尤其是他的关于奥运火炬事件的评论和其他评论(好像是他在日本韩国采访的感言)。感觉白岩松和汪峰长得挺像的。汪峰是我欣赏的歌手之一。

    我知道山东老乡毕福剑。2007年探亲时看到过他的一次节目,当时不太喜欢他,但感觉他在小品里演的挺好。

    罗大佑、李宗盛、周华健、和张震岳的组合挺不错。他们的新歌,名字忘了,就很棒!我是大佑的铁杆歌迷。张震岳的歌我从未听过。欢迎读者推荐好歌给我。

    那些京剧、越剧等组合都很好。老歌串唱,《在希望的田野上》,《光荣属于八十年代的新一辈》等也很煽情,不错。

看来要把这些年我错过的春晚找来,已快进的方式看看,应当还是有收获地。

Comments (2)

Identify a proxy when automatic configuration script is used

Many, if not all, corporations control and monitor employees web surfing and email activities. Sometimes a company may choose to use automatic configuration script to enable employees’ web connection. This can be verified by:

  • Internet Explorer: Tools -> Internet Options-> LAN Settings -> “Use automatic configuration script”;
  • Firefox 3: Tools -> Options -> Advanced -> Network -> Settings… -> Automatic proxy configuration URL:

Sometimes you need to know a proxy server name or IP address. For instance, if you use Perl and would like to do an automatic binary install of a module, then you will need to define a proxy for cpan to use. This is the command to do that:

set HTTP_proxy=http://my.proxy.server:8000/

So obviously you need to know a proxy server name or IP address. To find that out, you need to copy the location where the automatic configuration script is located, put that address into your browser and open it. It will prompt you to save it as a file. Do that, then open the file up to search for proxy server names or IP addresses.

As a side, I was not able to install DBD::mysql on a Windows XP machine with cpan. I also tried to do manual installation from source code, with no success. I use ActiveState Perl 5.10 and 5.1.30-community MySQL Community Server (GPL). I stumbled into Strawberry Perl while doing research for that issue. Maybe I will check it out in the future.

Comments

Medium-sized drink

Note: I am looking at some of older draft posts in my blog. I removed a few that just had a title there but no content. I saw this one, which looks half-done and was written close to 2 years ago, but I have no idea what I intended to write for the rest of the post. So here it is. In any event, a 32 ounce medium-sized drink bottle is something to behold! Large size drink holds around 42 ounces, which should be slightly more than 30% bigger than the one pictured below.

A couple of weeks ago, I was in a rush and ordered a spicy grilled chicken sandwich from Wendy’s. I was thirsty too, so I requested a medium drink. I normally don’t go to fast food stores like McDonald’s, Burger King, Wendy’s, and such. When I do, I normally just ask for a cup of tap water. I was really surprised when the guy from the drive-thru window passed me this cup of drink:

Medium sized Wendy's drink

He must have seen the expression on my face. Before I said anything, he smiled and said: “Yup, that is a MEDIUM drink”

The gigantic bottle actually wouldn’t fit inside the cup holder of my Neon. This experience reminded me that when I was in Xiamen University in the early 90’s, we were all excited when McDonald’s opened its first store on ZhongShan Lu. In fact, well-educated university students worked fairly hard to get a part-time job there. I flipped burgers and mopped floors there for a couple of weeks, and even got brave enough to court a nice looking McDonald’s colleague, before she scared me away with some strange stories.

Comments (2)

Divine Performing Arts is sponsored by Falun Gong

By now it is almost like a yearly ritual. As Chinese New Year is drawing near, Falun Gong is doing a publicity campaign to promote its Chinese New Year gala performance around the world in marquee venues. The advertisement I saw along highways in Chicago calls itself Divine Performing Arts. Divine Performing Arts, what a name.

For unsuspecting Americans who are interested in Chinese culture, the Divine Performing Arts billboard can be attractive on surface but ultimately misleading, because nowhere did it mention that it is a front for Falun Gong. Therefore a number of unsuspecting people who went to the show last year were disappointed, to the point that they left before the show was even over, as mentioned in this NYT article.

Here is something I know, based on personal experience:

  • A good high school friend, who I shared a dorm with, played basketball and joked together for three years, went berserk after becoming a FLG convert, killed his wife, then committed suicide;
  • A good friend’s relative got sick, but refused to take medications, citing that contradicted with FLG belief.

Comments (6)

2009春节前随记

耶诞节前到芝加哥郊区的宜家家居买有瑞典风味的食品,慰籍老婆思乡之情。我们的车停到了这个商店的出口附近。这儿离入口有几步路的小距离。那天风大,天冷,路滑。安静内敛的老婆露出无厘头本色:“要不我们从出口倒着走进去,这样商店该不会不满意吧!”。逗得我和儿子哈哈大笑。

—–

儿子的学校要搞国际食品节,我们做了瑞典和中国的宣传海报。以下是我们做的中国海报。大部分的字是我写的。感觉我的硬笔书法,和庞中华的有一拼!

学校画报

—–

上周五晚上听到了厨房里有咯吱咯吱的声音,当时就怀疑是老鼠。我拿了用来排浴缸堵水的活塞来赶,打开橱门后,老鼠已经跑了。装在纸袋子里的一些干面包被咬开,还被拖出来一块。这老鼠应当是从楼里的水管道里来的。

说来在这个两室一厅住了近9年了。中间好像记得有过一次老鼠。那次我用胶布封住了靠墙的一个小口,以后老鼠就没再来。上周五晚上我们再次用胶布封口,并把食品移开。到目前为止没感到有老鼠到访的迹象。今天给物业管理公司打了电话,希望他们有办法处理一下。现在对我们这栋楼的物业管理公司信心不大。他们卫生打扫的越来越差劲,但价格升得可快了。

—–

今年春节,我打算再次包饺子。小时候过年的那些活动,如炸馓子,炸萝卜和地蛋(土豆)丸子,放鞭炮,喝冰雪露、金奖白兰地等,都不太可能复制。对联儿还是要写的。嗯,还要考虑一下其他一些活动。

Comments

儿子写小诗

Note: for people coming here from PlanetMySQL, my apologies. I actually published this post on Friday evening and it was not in the MySQL category, as far as I remember (I am usually careful with things like that). But today it showed up under MySQL in my WordPress. Very bizarre…

儿子的圣诞新年放假两个星期。老师布置了个写诗的作业。儿子的诗写得挺有趣。

作业完后要求最好四个成人点评。我们家就我们两口子,所以就分别写了很短的点评,因为那纸上没留多少空。

摘录下我的:

Poetry? What are you talking about!

Delightful it is reading your poems,
Smiles they bring to my face.
O, please, write some more,
‘Cause poor Dad eagerly awaits!

注:”What are you talking about!” is the phrase for a kind of running joke in the family at the moment;
儿子的最后一首诗写了他如何不喜欢写诗,所以write some more也算是和他开个玩笑。

Comments

Interesting things about TIMESTAMP data type in MySQL

TIMESTAMP is interesting in that it can give you an easy way of keeping track of when was the last time a row was modified, with a few caveats, listed below. The tests were run on 5.1.30-community MySQL Community Server (GPL).

  • By default, TIMESTAMP is NOT NULL. Inserting a NULL value causes it to store the current DATETIME;
    mysql> CREATE TABLE t1 (c1 TIMESTAMP);
    Query OK, 0 rows affected (0.11 sec)
    
    mysql> INSERT INTO t1 VALUES (NULL);
    Query OK, 1 row affected (0.03 sec)
    
    mysql> SELECT * FROM t1;
    +---------------------+
    | c1                  |
    +---------------------+
    | 2008-12-30 20:42:25 |
    +---------------------+
    1 row in set (0.00 sec)
    
    mysql> CREATE TABLE t2 (c1 TIMESTAMP, c2 TIMESTAMP);
    Query OK, 0 rows affected (0.06 sec)
    
    mysql> INSERT INTO t2 VALUES (NULL, NULL);
    Query OK, 1 row affected (0.02 sec)
    
    mysql> SELECT * FROM t2;
    +---------------------+---------------------+
    | c1                  | c2                  |
    +---------------------+---------------------+
    | 2008-12-30 21:02:04 | 2008-12-30 21:02:04 |
    +---------------------+---------------------+
    1 row in set (0.00 sec)
    
  • TIMESTAMP falls between ‘1970-01-01 00:00:01′ and ‘2038-01-19 03:14:07′, according to Paul DuBois’ excellent MySQL 4th Edition book. Testing on one of my machines (Windows) shows that it varies a bit, but not much. Maybe this has something to do with hardware and/or operating system (Update, please see comment and my verification below, thanks to reader kimseong);
    mysql> INSERT INTO t1 VALUES ('2038-01-19 03:14:07');
    ERROR 1292 (22007): Incorrect datetime value: '2038-01-19 03:14:07' for column '
    c1' at row 1
    mysql> INSERT INTO t1 VALUES ('2038-01-19 03:14:06');
    ERROR 1292 (22007): Incorrect datetime value: '2038-01-19 03:14:06' for column '
    c1' at row 1
    mysql> INSERT INTO t1 VALUES ('2038-01-18 03:14:06');
    Query OK, 1 row affected (0.03 sec)
    
  • Only the first not null column can have the on update current_timestamp property. Remember, by default, timestamp is not null;
    mysql> CREATE TABLE t1(c1 INT, c2 TIMESTAMP DEFAULT CURRENT_TIMESTAMP, c3 TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
    ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
    
    mysql> CREATE TABLE t3 (c1 TIMESTAMP, c2 TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
    
    ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP
    column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
    mysql> CREATE TABLE t3 (c1 TIMESTAMP NULL, c2 TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
    Query OK, 0 rows affected (0.06 sec)
    
    mysql> CREATE TABLE t4 (c1 TIMESTAMP NULL, c2 TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, c3 TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
    ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
    
  • With the on update current_timestamp property of a timestamp column, one can use it to determine when a particular row was last modified. However, if the modification simply resets a column to its current value (essentially no data change), that particular timestamp column will not be updated.
    mysql> CREATE TABLE t6 (c1 INT, c2 CHAR(2), c3 TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
    Query OK, 0 rows affected (0.06 sec)
    
    mysql> INSERT INTO t6 VALUES (1, 'a', null);
    Query OK, 1 row affected (0.01 sec)
    
    mysql> SELECT * FROM t6;
    +------+------+---------------------+
    | c1   | c2   | c3                  |
    +------+------+---------------------+
    |    1 | a    | 2008-12-30 21:37:20 |
    +------+------+---------------------+
    1 row in set (0.00 sec)
    
    mysql> UPDATE t6 SET c2 = 'b' WHERE c1 = 1;
    Query OK, 1 row affected (0.03 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    mysql> SELECT * FROM t6;
    +------+------+---------------------+
    | c1   | c2   | c3                  |
    +------+------+---------------------+
    |    1 | b    | 2008-12-30 21:38:12 |
    +------+------+---------------------+
    1 row in set (0.00 sec)
    
    mysql> UPDATE t6 SET c2 = 'b' WHERE c1 = 1;
    Query OK, 0 rows affected (0.00 sec)
    Rows matched: 1  Changed: 0  Warnings: 0
    
    mysql> SELECT * FROM t6;
    +------+------+---------------------+
    | c1   | c2   | c3                  |
    +------+------+---------------------+
    |    1 | b    | 2008-12-30 21:38:12 |
    +------+------+---------------------+
    1 row in set (0.00 sec)
    

Comments (7)

恋曲2008

2008,多么难忘的一年!

博客上来讲,去年共写90篇。把它们(非IT类)罗列下来,也算是个人的对2008的不完整的一些记录。

一月
这篇写了我2007年底和2008年初读的一些儿童读物。很有趣,我现在正给儿子读托尔金的《魔戒前传》,英文原版The Hobbit。有空把这个中译本弄过来读读。前几天还和老婆闲聊,觉得书中的那些精灵怪兽的歌词的翻译应当很有挑战性,因为那里有很多精妙的英文押韵和用词。

在这儿写了在杭州时钱塘观潮的一些尴尬。

这篇记录了2007年在北京的一些事儿。

喜欢许巍和伍佰的歌

看姚明打球。

二月

二月雪灾时很多人回家过年受影响,给博客加黄丝带表示支持。现在那个黄丝带的链接已失效。

记录了我很佩服的肯-亨德森去世后的感想。

三月

记录故国行坐火车的感受

四月

顶一下中华捐书会,The Library Project,捐了点小钱,并会继续支持。

记录了奥运前的一些事件和自己在美国的感同身受及想法。本打算用中英文写,但因没时间和精力,用得是英文。

同上

真世界。同样是有感而发,其实觉得提到的那些情况和挑战不只仅在中国。个人认为越南、印度、墨西哥、巴西、阿根廷、巴勒斯坦、古巴、委内瑞拉等国也会有同样的问题和挑战。感觉萨伊德的东方主义还有诺姆-乔姆斯基的关于主流媒体的论述很一针见血

打喷嚏后的礼貌用语。

五月

大地震,有感而发,和你在一起。并继续祝福灾区的人们。

对网络现象的评论,有感而发。

六月

在美国坐车上班,乱写一通。

杜绝浪费,保护环境,从我做起。

七月

如何有效的安排自己的时间,是个大问题。

写一些饮食方面的趣事。

夏天的一些照片。

有感而发,自己的宗教经历之一。

有感而发,自己的宗教经历之二。

欢迎你到中国来!

同上。

有感而发,自己的宗教经历之三。

八月

有感而发,自己的宗教经历之四。

奥运开幕式很好很强大!

2007故国行高中同学聚会。

观奥运。

怎样烙煎饼和我爱吃的煎饼卷大葱老咸菜!

九月

顶一下老谋子。偶以为他搞的开幕式太牛逼了。

鸡眼。说实话,臭脚丫子的味道和法国的一些奶酪(Brie)味道相似,不过这玩意儿和一些臭豆腐一样,闻起来臭,吃起来香。也有一些法国奶酪闻起来像化肥。具体说来,有些像尿素,我们家乡话叫骚肥。

支持海外中国教育基金,捐了点小钱。还会继续支持。

十月

温家宝总理接受美国记者采访的录像。

世界经济问题。个人感觉美元外汇和美国国债这些东东,要有并要到一定规模。但太多对双方都不利,还当冤大头,一到竞选时就挨骂。钱花到刀刃上,引进消化高新技术,外汇储备多元化(欧元,日元,英镑,加元,克朗等),国内西部和农业投资,和不至于触动所在国保守主义的投资等都要考虑。我虽是经济专业出身,但毕业后根本就没有用上。这些都是本人瞎琢磨。

自我批评和决心书,关于个人时间的统筹安排。

说了说2007年回老家季庄的事儿。

调整巩固充实提高。

冀朝铸的英文回忆录读后杂感,乱写一通。

十一月

2007年在江南旅游的一些片段。

十二月

看美国二战宣传片的杂感。

参与美国选举的一些经历和感想。

在纽约亚洲中心关于中国、世界环境的纪录片和讨论。

同上。

年终放假的一些照片。

觉得这一年有一个很有趣的现象:网上和市井里那么多的关于2008的荒唐的流言和谣传,好像都没应验吧。还是觉得温家宝总理说得好:最重要的是要对自己有信心。引申一下,少一些自卑、自负、和悲情,多一些自尊、自信和自强。如胡哥的报告中提到,不动摇,不懈怠,不折腾。

祝读者新年愉快!

Comments (2)