0

You can check the character set of show create table 'table', show create database 'database', \s with db, table, system.

What character set does this table use if the situation is as below?

If the client is utf8mb4 and the table is utf8mb4, there is no problem using it as utf8mb4. Can I ignore all other settings?

1.
mysql > show create database db_name;
+-----------+----------------------------------------------------------------------+
| Database  | Create Database                                                      |
+-----------+----------------------------------------------------------------------+
| db_name   | CREATE DATABASE `db_name` /*!40100 DEFAULT CHARACTER SET latin1 */   |
+-----------+----------------------------------------------------------------------+

2.
mysql > show create table tb_name;
CREATE TABLE `tb_name` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `var` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

3.
\s
Server characterset:    utf8
Db     characterset:    latin1
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
  • The character set in your example table is clearly `utf8mb4`. What are you asking in particular and what do you mean by _"ignore all other settings?"_ – kmoser Aug 10 '20 at 01:52
  • I'm sorry. I didn't have enough explanation. server and db are not utf8mb4. I was wondering if it was only necessary to have a table charter set of utf8mb4 in this state. – user1819769 Aug 10 '20 at 01:59

1 Answers1

0

Every column has its own character set and collation; the table, database, and server character sets are simply the defaults for newly created new columns, tables, and databases (respectively). But show create table will show the character set for any columns that differ from the table default, so if you don't see any, the table's character set is what its columns are using.

ysth
  • 96,171
  • 6
  • 121
  • 214