22

I created a database schema using MySQL Workbench's data modeling tool. When it generates the SQL CREATE statements, it generates "default character set = latin1;" for some tables, e.g.:

-- -----------------------------------------------------
-- Table `moocdb`.`resource_types`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `moocdb`.`resource_types` (
  `resource_type_id` INT(11) NOT NULL,
  `resource_type_name` VARCHAR(20) CHARACTER SET 'utf8' NOT NULL,
  PRIMARY KEY (`resource_type_id`))
ENGINE = InnoDB
default character set = latin1;

How can I change it to the schema's default character set? (I found where to change the schema's default character set, but not the table's)


As a side note:

Note: Since MySQL 5.5.3 you should use utf8mb4 rather than utf8. They both refer to the UTF-8 encoding, but the older utf8 had a MySQL-specific limitation preventing use of characters numbered above 0xFFFD.

3
  • Possible duplicate of MySQL Workbench charset Jul 12, 2018 at 18:28
  • @BrianTompsett-汤莱恩 those are different questions: the question you linked to is trying to change some MySQL workbench configuration whereas in my question I want to change the database itself. Jul 12, 2018 at 18:31
  • Thanks. The duplicate came from the answer posted today (from the late answer review queue...). Your comment will be useful to anyone who sees it. Jul 12, 2018 at 18:52

5 Answers 5

57

You can set the used charset/collation combination in the table editor. You have to expand the header (which is by default collapsed to save space) to be able to change it. See this screenshot:

enter image description here

2
  • Is it safe to change the collation on a live production database? What exactly does it do?
    – Vincent
    Feb 6, 2019 at 0:39
  • Please don't use answers to post new questions. Instead create a new question. Feb 6, 2019 at 7:47
4

Thanks a lot for this topic : it saves me a lot of time (I searched the header that was just collapsed by default).

I just want to say that you can specify for the table collation the option : schema default (the first option in the collation drop list).

And then, you can specify too the collation for the text type fields : table default.

With that, you can control the collation of your database with just the global schema collation parameter.

(my mysql workbench version : 6.1.7 revision 11891 build 1788)

Enjoy

1
  • 3
    Where can I change that global schema collation parameter? Nov 14, 2017 at 4:53
3

Expand the database. Select the table from the tree view-> Right click and select alter table. You will get the following window shown in the screen shot. Here you can change the charset.enter image description here

1

To change the entire database in the work bench...

In "Model Overview", under "Physical Schemata", right-click the database and select "Edit Schema...". Define the character set to the "Collation"-field. (MySQL Workbench 5.2.35)

Answered here: https://stackoverflow.com/a/8149026/5579664

0

When you open your model, double click (or right click and edit) on MySQL schema, and MySQL Workbench show you, settings for Charset/Collation like as figure

First Case

Second Case

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.