Search code examples
mysqlutf-8utf8mb4

Can I safely use a utf8 connection with utf8mb4 columns?


As long as all tables in my database are not migrated to utf8mb4, is there a risk of continuing to use a utf8 connection?

I thought keeping the utf8 connection until all the tables are migrated.

The underlying question is: how long will it take to make changes on very large tables (hundreds of GB)?


Solution

  • As long as all the data is in the 3-byte utf8 subset, utf8 and utf8mb4 are identical.

    The connection parameters (including SET NAMES) specify the encoding in the client. The column/table definition says what encoding is handled in the columns. MySQL will convert between those as you INSERT or SELECT. Again, as long as all the data is utf8 subset, the conversion is possible (effectively a no-op).