Database Character Set Problems

Source: Internet
Author: User

Database Character Set Problem 1. list all CHARACTER sets supported by MYSQL: show character set; 2. the current MYSQL Server character set shows variables like 'character _ set _ % '; 3. the current MYSQL Server character set verification settings show variables like 'collation _ % '; 4. displays the name of the show create database set in a database character set; 5. display the name of the show create table set for a data table; www.2cto.com 6. modify the database character set alter database name default character set 'utf8'; 7. modify the character set of the data table alter table name default character set 'utf8'; 8. specifies the character set when creating a database. create database name ch Aracter set gbk collate gbk_chinese_ci; 9. create table 'mysqlcode' ('id' TINYINT (255) unsigned not null AUTO_INCREMENT primary key, 'content' VARCHAR (255) not null) TYPE = myisam character set gbk COLLATE gbk_chinese_ci; library character set, in my. the following code is missing in cnf: [client] default-character-set = utf8 [mysqld] default-character-set = utf8 if the above Code is not added, even if the encoding specified during MYSQL compilation and installation is UTF8, the default encoding is LATIN1 during database creation. Due to the inheritance of the character set, the tables in the database It's also LATIN1. In windows: www.2cto.com 1. In windows, you can use a statement similar to the following. Run the command line to enter the directory of mysql/bin. D: \ usr \ mysql41 \ bin> mysqldump-uroot-p -- quick -- compatible = mysql40 -- default-character-set = latin1 -- extended-insert = FALSE test2> d: \ zzz. SQL test2 is the name of the database you want to export data, d: \ is the path, set it to the path you want, zzz. SQL is a randomly named file with a random name. the SQL suffix is enough. The program will prompt you to enter the root user password (if there is a password), enter it, and the program will start exporting. MB of data is finished in 2-3 minutes. 2. Step 2, create a new library through phpmyadmin, Database Name: test, collection Character Set set to utf8-general-li or gb2312 www.2cto.com 3, import the backed up SQL file into the new database. D: \ usr \ mysql41 \ bin> mysql-uroot-p -- default-character-set = utf8 test <d:/zzz. SQL or D: \ usr \ mysql41 \ bin> mysql-uroot-p -- default-character-set = gb2312 test <d: \ zzz. SQL takes a relatively long time, And MB of data takes about 10 minutes. Author: a442180673

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.