Using a Linux client to execute shell scripts to create database initialization database Chinese garbled problem

Source: Internet
Author: User

  1. Defines a shell script that can create a database from several other SQL files, and initializes the database with a SQL file that contains the initialized data.

  2. Using a Linux client to connect to a Linux server under Windows, after executing the shell script, it is found that the database created is garbled in Chinese.

  3. OK is a character set setting problem. Look at the database and discover that the character set settings are as follows, many or latin1.

    mysql> Show variables like ' character_set_% ';
    +--------------------------+----------------------------+
    | variable_name | Value |
    +--------------------------+----------------------------+
    | character_set_client | latin1 |
    | character_set_connection | latin1 |
    | character_set_database | latin1 |
    | character_set_filesystem | binary |
    | character_set_results | latin1 |
    | character_set_server | latin1 |
    | character_set_system | UTF8 |
    | character_sets_dir |/usr/share/mysql/charsets/ |

  4. Modifying the default character set

  5. Modify File/etc/my.cnf Content

    Under [client], add the following statement

    Default-character-set=utf8

    Add under [mysqld]


    Default-character-set=utf8

    init_connect= ' SET NAMES UTF8 ' # #设定连接mysql是使用UTF8编码

    Once modified, restart the MySQL service to


Using a Linux client to execute shell scripts to create database initialization database Chinese garbled problem

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.