I have a table defined as follows:
mysql> show create table temptest;
+------------+-----------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------+-----------------------------------------------------------------------------------------------------------+
| temptest | CREATE TABLE `temptest` (
`mystring` varchar(100) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+------------+-----------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
When I use mysql console (through mysql temptest) and insert a character through
insert into temptest values ("é");
I can see it is getting saved as "latin1" encoding
mysql> select hex(mystring) from temptest;
+---------------+
| hex(mystring) |
+---------------+
| E9 |
+---------------+
But if I issue a "set names latin1" and perform the same operation, I see it storing the same character in utf8 encoding.
mysql> set names latin1;
Query OK, 0 rows affected (0.00 sec)
mysql> insert into temptest values ("é");
Query OK, 1 row affected (0.01 sec)
mysql> select hex(mystring) from temptest;
+---------------+
| hex(mystring) |
+---------------+
| E9 |
| C3A9 |
+---------------+
As far as I understand, "set names" shouldn't affect how mysql stores the data (https://dev.mysql.com/doc/refman/8.0/en/set-names.html). What am I missing here? Any insight into this would be greatly appreciated. Thank you.