Subscribe to RSS Subscribe to Comments Blog of Roy Chan

Blog of Roy Chan

Fix the MySQL character set problem after MySQL 4.1 forever!

I suppose many people had mention it before. It is talk about the output of your database become rubbish after you upgrade from older MySQL to 4.1. Experience people should senses that it is the problem because MySQL 4.1 get more support on multi-language and charset. You or me may already got the same experience in Oracle/Java and know that we should correct the charset of the MySQL server and client. However, the solution in people’s blog is in chaos.

Some ask you to “SET NAME utf8″ after each connection. Oh, that you need to search “mysql_connect” or “mysql_pconnect” in all your PHP application and put “mysql_query('SET NAME utf8')” after them. You may look through your php.ini or httpd.conf and see if you change the default client charset in PHP/apache but the fact is that the default client charset is fixed libmysql before compilation. You don’t want to compile libmysql again by yourself, right? Some ask you to put init-connect='SET NAME utf8‘ in my.cnf but it never works. Some said it should be init_connect instead of init-connect but still no luck. Some ask you to set default-character-set in section [mysql] of my.cnf but you want PHP will connect with UTF-8 by default too. Ok, here is the solution. What you need is add “default-character-set=utf8 in both [client] and [mysqld] sections in your my.cnf:



The MySQL will use UTF8 after restart it. You can check it by typing the following in mysql:

SHOW VARIABLES LIKE 'character_set%';


Share It: [] [Technorati] [Google Bookmark] [Yahoo MyWeb] [Furl]

Postfix and new server

HKLUG’s Alpha DS10 is fucked up. It seems the harddisk is dying. Therefore, I’m trying to migrate every thing out. I have moved the main website and wiki to new niet and spent sometime to migrate the mail services. I decided to use Postfix instead of Exim and try to use MySQL as the forward table. However, the postfix fail to connect MySQL. Finally, I aware that postfix jail some processes under chroot environment and make them unable to access MySQL via Unix socket. After some consideration, I decide to switch on the TCP/IP connection of MySQL but blocking connection from outside via netfilter. Now, it work smoothly.

Today, I also migrate most websites to new niet.


Share It: [] [Technorati] [Google Bookmark] [Yahoo MyWeb] [Furl]

PHP 4.0.1pl2 for Debian Potato

最近呢部 Server 成日有事,主要因為:

  • 加左 HD, 好多野要拾
  • 大枝野 幫手 …, 本站由 Debian GNU/Linux 2.1 (Slink) 升級左去 2.2 (Potato)
  • 因為發現 Potato 中的 PHP4 係 beta 版 .. 個 Perl 兼容 RE 好鑊.. 索性羅 左 Woody 中既 PHP 4.01pl2 .. compile for Potato..

1pl2 for Potato 有興趣.. 可以係搵 .. MySQL 2.23 都 compile 左 .. 不過我想 check 好 d 先方上唻 .. apt/dselect 可以係 /etc/apt/source.list 加上:

deb potato free non-free

Share It: [] [Technorati] [Google Bookmark] [Yahoo MyWeb] [Furl]

Sth about Web

Here is something about web.. let see when I will have time to read it:

  • Why Not MySQL
    OpenACS talk about why they don’t use MySQL as their Web RDBMS. (Slashdot) (OK, I still use MySQL personally, it not the best.. but suit my need)
  • Which CGI Language For Which Purpose?
    Slashdot discussion about Which Web Server language should be use. (PHP and Perl is still my favorite)
  • Analog
    kwan give me this link last night.. an Web log analysis program… But I’m writing my own one ;P… Basically, I prefer Webalizer more…
  • How to build a lame site
    Another link that kwan give me last night. Sure.. you know what she mean.

Share It: [] [Technorati] [Google Bookmark] [Yahoo MyWeb] [Furl]

Based on Fluidity© 1998-2007 Roy Hiu-yeung Chan