Solutions for retrieving MySQL encoding and conversion

Source: Internet
Author: User

The following articles mainly talk about the actual steps of MySQL encoding conversion and MySQL encoding conversion. I found a piece of information about MySQL encoding conversion on a reputable website for your sharing, I hope it will help you in this regard.

Many modern applications support multiple languages. Therefore, if MySQL is used in the database, utf8 encoding is generally recommended to store multilingual data. Another reason is that most development languages such as. NET and JAVA currently use unicode processing programs in the program itself. MySQL can avoid Code Conversion between databases and programs after utf8 is used.

MySQL encoding and conversion 1. Server encoding settings.

MySQL server 5 can select the database encoding when installing it in windows, but it does not work in linux. The default encoding is litan1. Therefore, you need to modify the configuration file, in windows, the configuration file is my. ini, the configuration file in linux is/etc/my. cnf: Add default-character-set = utf8 to [client] and [MySQLd] respectively, restart the service (the command is service MySQL restart in linux), and enter show under MySQL>, in the result, all character_set_xxxx values are displayed as utf8, indicating that the configuration is successful.

MySQL encoding and conversion 2. Application configuration.

Java: jdbc: MySQL: // 192.168.1.231: 3306/dbname? UseUnicode = true & characterEncoding = UTF-8

Net: Server = 127.0.0.1; Database = dbname; User Id = root; Password = 123456; Charset = utf8

Change the ip address and dbname to the one specified by the system.

MySQL encoding conversion 3. Existing database encoding conversion.

If some databases use litan1 encoding, You need to convert it to utf8 for better use.

A. MySQLdump -- default-character-set = latin1-uroot-p123456 dbname> 1. SQL

B. Use editplus or another editing tool to open 1.sqland convert latin1 to utf8. (The data cannot be imported after being converted using ultraedit in the test. I do not know the reason ).

C. MySQL-u root-p 123456 dbname <1. SQL

Import the converted SQL file to the new database.

Related Article

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.