Changing the default character set of a table doesn't alter any of the existing columns. You can run SHOW CREATE TABLE MyTable
and see the difference.
For example, we can create a table with an old-fashioned charset:
mysql> create table MyTable (string1 varchar(100) ) default character set = latin1;
mysql> show create table MyTable\G
*************************** 1. row ***************************
Table: MyTable
Create Table: CREATE TABLE `MyTable` (
`string1` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
Next, we change the table's default, but we see that does not change the column. The existing column automatically gets an option showing us what it actually uses for a charset, since it's now different from the table default:
mysql> alter table MyTable default charset = utf8mb4;
Query OK, 0 rows affected (0.04 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table MyTable\G
*************************** 1. row ***************************
Table: MyTable
Create Table: CREATE TABLE `MyTable` (
`string1` varchar(100) CHARACTER SET latin1 DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
1 row in set (0.00 sec)
The default is used for columns added to the table subsequently:
mysql> alter table MyTable add column string2 varchar(100);
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table MyTable\G
*************************** 1. row ***************************
Table: MyTable
Create Table: CREATE TABLE `MyTable` (
`string1` varchar(100) CHARACTER SET latin1 DEFAULT NULL,
`string2` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
To convert the existing column, use CONVERT TO CHARACTER SET. This rewrites the table, converting the existing data of each column if needed:
mysql> alter table MyTable convert to character set utf8mb4;
Query OK, 0 rows affected (0.09 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table MyTable\G
*************************** 1. row ***************************
Table: MyTable
Create Table: CREATE TABLE `MyTable` (
`string1` varchar(100) DEFAULT NULL,
`string2` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
Now both columns say nothing about their respective charsets, because they match the table's default.