MySQL configuration file location:/etc/mysql/my. cnf. database Table Folder:/var/lib/mysql/. log on to MySQL in the date folder of MySQL under Windows in UbuntuLinux and execute the code: showvariableslike 'character % '; + ------------------------ + ---------------------
MySQL
Main configuration file location:/etc/mysql/my. cnf.
Database Table Folder:/var/lib/mysql/, which is equivalent to the date folder of MySQL in Windows in Ubuntu Linux
Log on to MySQL and run the encoding:
Show variables like 'character % ';
+ -------------------------- + ---------------------------- +
| 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/|
+ -------------------------- + ---------------------------- +
Modify the encoding of the default MySQL database
You need to edit the my. cnf file. For Windows, you can directly use Mysql Server Instance Config Wizard to set
Sudo gedit/etc/mysql/my. cnf
Find [client] and add:
Default-character-set = utf8 // The default character set is utf8
Find [mysqld] and add:
// The default character set is utf8.
Default-character-set = utf8
// Set utf8 encoding when connecting to the mysql database to run the mysql database as utf8
Init_connect = 'set NAMES utf8'
After modification, restart mysql.
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/|
+ -------------------------- + ---------------------------- +