Mysql 5.0.22 in Linux

Source: Internet
Author: User

Especially when I cannot find my. cnf, I should take it seriously.

Author: Fan guanqun

After a few days of desperate Baidu and continuous experiments, I finally solved the problem of Mysql 5.0.22. Online articles are neither too long nor too important, nor too many Windows articles and Linux articles. Next I will talk about my experiences in the following steps:

I. Environment:
// It can be solved in other environments.
Hongqi Linux5.0, java1.5.0-beta2, mysql 5.0.22, hibernate2.1

Ii. Symptoms
1. When the data in the program is stored in the database, the Chinese character becomes a question mark.
2. When reading data from the database, Chinese words are still a bunch of greetings.

3. Solution steps
If (my. cnf exists in the/etc directory ){
Open the my. cnf file and find the word [mysqld.
// Explanation: default-character-set = gb2312 is the default character set for the database.
// The equal sign can be followed by other characters, such as UTF-8.
// If this row is not written in such a file, the default Character Set of the database is litan.
// This is the reason for Chinese garbled characters
Add a default-character-set = gb2312 row under it.
Save the my. cnf File
} Otherwise, if (my. cnf does not exist in the/etc directory ){
// Explanation:
// The installation directory of mysql is/usr/share/mysql if you use rpm for installation.
// If you decompress the package without installation, it will be in the decompressed folder.
Locate my-small.cnf, my-medium.cnf in the installation directory of mysql
, My-large.cnf and other similar naming file security needs to take;
// Explanation: I only need a small default configuration for mysql.
I get my-small.cnf
Open the my-small.cnf file and find the word [mysqld.
Add a default-character-set = gb2312 row under it.
Save as my. cnf File
Copy my. cnf to the/etc directory.
}
Restart the computer. (I want to restart mysql. If you haven't tried it, you can try it ).

For example, if the database used in your program is testdb, You need to delete testdb and recreate testdb and all tables in it.

Mysql now supports Chinese, without having to modify code writing or other settings. Note that you must delete the test database and recreate the test and all the tables in it. Otherwise, garbled characters will occur.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.