系统自带的MySQL默认字符集不是gbk,因此给数据库的推广应用以及中文程序的开发带来极大的不便,在没完没了的GBK和UTF8的转换过程中消耗了我们无数的精力以及系统的资源。
先将让slack支持中文,然后重新编译MySQL,原来系统MySQL的要先卸载:
<ccid_code></ccid_code>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 |
再下载MySQL4.x.x:
<ccid_code></ccid_code>shell> gunzip 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 根据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。
再回上一步:
<ccid_code></ccid_code>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 .... |
在UTF8字符集的老数据库中,创建中文支持表脚本如下,对字段加上字符集说明:
<ccid_code></ccid_code>CREATE TABLE `test`.`cn` ( `zh` CHAR(10) CHARACTER SET gb2312 COLLATE gb2312_chinese_ci NOT NULL, `中文` INT(11) NOT NULL ) ENGINE = MYISAM; |
对于新创建的数据库加个默认字符集声明GBK,就不用建表时候每个字段声明了,这样看起来简单流畅,没有特殊的痕迹,建议多采用这种方法。
<ccid_code></ccid_code>mysql> CREATE DATABASE dbCN DEFAULT CHARACTER SET gbk COLLATE gbk_chinese_ci; CREATE TABLE `dbCN`.`cn` ( `zh` CHAR(10) NOT NULL, `中文` INT(11) NOT NULL ) ENGINE = MYISAM; mysql> insert into cn values("真的?",1); |
<ccid_code></ccid_code>shell> bin/mysql -u root --default-character-set=gbk -p mysql>use test mysql> select * from cn; +--------+------+ | zh | 中文 | +--------+------+ | 真的?| 1 | +--------+------+ 1 row in set (0.00 sec) ----------------------------- |
最后修改启动文件/etc/rc.d/rc.mysqld,改路径/app/mysql/bin/mysqld_safe,改路径/app/mysql/var/web.pid最后/app/mysql/bin/mysqld_safe 后面加入 --user=root --default-character-set=gbk。

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools