由于系统自带的MySQL默认字符集不是gbk,因此给数据库的推广应用以及中文程序的开发带来极大的不便,在没完没了的GBK和UTF8的转换过程中消耗了我们无数的精力以及系统的资源。
先将让slack支持中文,然后重新编译MySQL,原来系统MySQL的要先卸载:
login:rootshell> removepkg mysqlshell> groupadd mysqlshell> cd /appshell> mkdir mysqlshell> chmod 744 mysqlshell> useradd -G mysql -s /bin/bash –p /app/mysql mysqlshell> chown -R mysql.mysql mysql |
再下载MySQL4.x.x:
shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -shell> cd mysql-VERSIONshell> CFLAGS="-O3 -mcpu=pentium3" \CXX=gcc \XXFLAGS="-O3 -mcpu=pentium3 -felide-constructors" \./configure --prefix=/app/mysql \--with--charset=gbk \--with-extra-charsets="gbk gb2312 big5 utf8"\--with-unix-socket-path=/etc/mysql.sock \--enable-local-infile \--enable-thread-safe-client \--enable-assembler \--with-client-ldflags=-all-static \--with-mysqld-ldflags=-all-static |
//-mcpu 根据CPU类型优化编译,可以让你的MySQL表现更好。可选项目很多:i386, i486, i586, i686, pentium, pentium-mmx, pentiumpro, pentium2, pentium3, pentium4, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-4, athlon-xp,athlon-mp,winchip-c6, winchip2 , c3。执行:shell> make。错误时候执行:shell> make clean。
再回上一步:
shell> make installshell> cp support-files/my-medium.cnf /etc/my.cnfshell> cd /app/mysqlshell> bin/mysql_install_db --user=rootshell> chown -R root .shell> chown -R mysql varshell> chgrp -R mysql .shell> ./bin/mysqld_safe --user=root --default-character-set=gbk &shell> ./bin/mysqladmin -u root password 'new-password'shell> ./bin/mysql -u root --default-character-set=gbk -pmysql> status...Server characterset: gbkDb characterset: gbkClient characterset: gbkConn. characterset: gbk.... |
<