Correcting default encoding

Source: Internet
Author: User
Modifies the default encoding.
This code really messed up.
When the database server was installed, no database encoding was selected. Querying database encoding
PHP Code
  
   Show create database guest;

All of them are latin1. Search the next Google,
There are a few questions,
Can 1:default-character-set=gb2312 change the overall situation? (That is, modify the database server default character set)
2: The default has been latin1, the creation of the database did not specify the encoding, this time should also be Latin it?
PHP connection to the database this part, if I specify the encoding, this time is OK?
PHP Code
  
   mysql_query (set names gb2312)

It seems to be written like this, novice don't blame.

------Solution--------------------
Default-character-set in My.ini is the default character set for MySQL
Need to restart MySQL if modified
If you modify, you need to take into account the needs of other users!

If not modified, the character set is not involved in all MySQL applications. This will return to the origin of the database.

In fact, MySQL introduced the concept of character sets, but there is no subsequent action. For example, full-text search is still not available

------Solution--------------------
When you create a database, you set the encoding you need, such as UTF8 GBK
PHP operation database when the execution
mysql_query ("Setnames utf8"); or Setnames GBK.

The output page specifies the appropriate encoding when the data set is obtained

Header ("content-type:text/html; Charset=utf-8 "); or GBK

If it is utf-8 file encoding remember to also save the appropriate encoding

Such...
///////////////////////////////////
Export your data, re-set the database encoding and then import the data and then refer to the above method operation should be OK.
  • 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.