Summary: The system comes with the MySQL default character set is not GBK, so the application of the database and the development of Chinese programs bring great inconvenience, in the endless GBK and UTF8 conversion process consumes our countless energy and system resources. After groping to solve the problem of Chinese support, Experience to share with you.
First will let slack support Chinese, the method can see "linuxsir.org slackware Discussion Area", and then recompile MySQL, the original system MySQL to use uninstall first.
Login:root
shell> removepkg MySQL
shell> Groupadd MySQL
Shell> Cd/app
shell> mkdir MySQL
shell> chmod 744 MySQL
shell> useradd-g mysql-s/bin/bash–p/app/mysql MySQL
shell> chown-r mysql.mysql MySQL
Download mysql4.x.x
Shell> Gunzip < mysql-version.tar.gz | TAR-XVF-
Shell> CD Mysql-version
shell> 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 based on the CPU type to optimize the compilation, you can make your MYSQ performance better! There are many items to choose from: I386, i486, i586, i686, Pentium, PENTIUM-MMX, Pentiumpro, pentium2, pentium3, Pentium4, K6, K6-2, K6-3, Athlon, Ath Lon-tbird, Athlon-4, Athlon-xp,athlon-mp,winchip-c6, Winchip2, C3.
Shell> make
------------------------------------------
Wrong time
Shell> Make Clean
One more step back.
-------------------------------------------
shell> make Install
shell> CP support-files/my-medium.cnf/etc/my.cnf
Shell> Cd/app/mysql
Shell> bin/mysql_install_db--user=root
Shell> chown-r Root.
shell> Chown-r mysql var
Shell> 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-p
mysql> status
...
Server CHARACTERSET:GBK
Db CHARACTERSET:GBK
Client CHARACTERSET:GBK
Conn. CHARACTERSET:GBK
....
See CharacterSet is all GBK even if successful.
--------------------------------------------
In the old database of the UTF8 character set, create the Chinese support table script as follows, add character set description to the field
CREATE TABLE ' test '. ' CN ' (
' Zh ' CHAR (CHARACTER SET gb2312 COLLATE gb2312_chinese_ci not NULL,
' Chinese ' INT (one) not NULL
)
ENGINE = MYISAM;
Note: CHARACTER SET write GB2312 and GBK can, GBK is better than gb2312.
For a newly created database with a default character set declaration GBK, you do not have to create a table when each field is declared, so that looks simple and smooth, there is no special traces, it is recommended to use this method more.
mysql> CREATE DATABASE dbcn DEFAULT CHARACTER SET gbk COLLATE gbk_chinese_ci;
CREATE TABLE ' DBCN '. ' CN ' (
' ZH ' CHAR (%) not NULL,
' Chinese ' INT (one) not NULL
)
ENGINE = MYISAM;
Mysql> INSERT INTO CN values ("Really?") ", 1);
Note: If these scripts are not entered using the Bin/mysql command line, you can use MySQL query Browser, or program execution.
-------------------------------------------
shell> bin/mysql-u Root--default-character-set=gbk-p
Mysql>use Test
Mysql> SELECT * from CN;
+--------+------+
| En | Chinese |
+--------+------+
| Is it true? | 1 |
+--------+------+
1 row in Set (0.00 sec)
---------------------------------------------
Last modified boot file/etc/rc.d/rc.mysqld
Change Path/app/mysql/bin/mysqld_safe
Change Path/app/mysql/var/web.pid
Join--user=root--DEFAULT-CHARACTER-SET=GBK behind/app/mysql/bin/mysqld_safe
Original link: http://slack.linuxsir.org/main/?q=node/165