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.
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.
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/ |
Modifying the default character set
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