Character Set setting of MySQL database server in Linux:
After mysql is started, log on to mysql as the root user
Isher @ isher-ubuntu :~ $ Mysql-u root
> Show variables like 'character % '; # display the code
+ -------------------------- + ---------------------------- +
| 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/|
+ -------------------------- + ---------------------------- +
In some cases, we need to modify the encoding of the default mysql database to ensure that some migrated programs can be properly displayed. edit my. modify the cnf file encoding. For windows, you can directly use Mysql Server Instance Config Wizard to set
Modify one of the three my. cnf files in linux:/etc/mysql/my. cnf
Find the client configuration [client] and add it below
Default-character-set = utf8 default character set: utf8
Add in [mysqld]
Default-character-set = utf8 default character set: utf8
Init_connect = 'set NAMES utf8' sets utf8 encoding used to connect to the mysql database to run the mysql database utf8)
After modification, restart mysql and query show variables like 'character % ';
+ -------------------------- + ---------------------------- +
| Variable_name | Value |
+ -------------------------- + ---------------------------- +
| Character_set_client | utf8 |
| Character_set_connection | utf8 |
| Character_set_database | utf8 |
| Character_set_filesystem | binary |
| Character_set_results | utf8 |
| Character_set_server | utf8 |
| Character_set_system | utf8 |
| Character_sets_dir |/usr/share/mysql/charsets/|
+ -------------------------- + ---------------------------- +
This method is also valid for the standard mysql version, for the/etc/my. cnf file, you need to copy from the mysql/support-files Folder cp my-large.cnf to/etc/my. cnf
For Ubuntu users, if Synaptic is used for installation
Here, the character set setting of the MySQL database server in Linux has been completed. The Character Set setting of the MySQL database server in Linux is often used in database operations, I hope that after learning this article, you can learn how to set the character set of the MySQL database server in Linux.