mysql> show variables like "%colla%";
---------------------- -----------------
| Variable_name | Value |
---------------------- -----------------
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
---------------------- -----------------
mysql> show variables like "%char%";
-------------------------- -----------------------------------------------
| 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 | C:\phpStudy\PHPTutorial\MySQL\share\charsets\ |
-------------------------- -----------------------------------------------
mysql> create table emp3(
-> `id` int(11) NOT NULL AUTO_INCREMENT,
-> `username` varchar(50) NOT NULL,
-> `balance` float NOT NULL,
-> `province` varchar(20) NOT NULL,
-> `age` tinyint(3) unsigned NOT NULL,
-> `sex` tinyint(4) NOT NULL,
-> PRIMARY KEY (`id`)
-> ) ENGINE=InnoDB CHARSET=utf8;
Query OK, 0 rows affected (0.03 sec)
Because the character encoding of the cmd command line is gbk, so what you insert is gbk encoded data, and your table is utf8 encoded, so the insertion will be garbled. You can try to build a gbk encoded data table and execute set names gbk;Then insert data into the command line