0

In this question: Running/Starting MySQL without installation on Windows, I have asked a question in the comment:

I see in many tutorials, there is a config file named my.ini. But in Aj Tech Developer's answer, this my.ini file is not needed, why?

Here is a my.ini file I used for my configuration:

[client]
default-character-set=utf8

[mysqld]
port = 3306
max_connections=20
character-set-server=utf8
default-storage-engine=INNODB

Question 1: It looks like if this file does not exist, the Mysql can still start correctly. So, is that file necessary?

Question 2: Whey I try to create a database in the running Mysql, it said the server side default collation is utf8mb3_general_ci, while in some discussion(mysql - What's the difference between utf8_general_ci and utf8_unicode_ci? - Stack Overflow), it is suggested that the utf8mb4_general_ci is preferred. So, I'm not sure what are their difference.

Thanks.

EDIT

The server side collation option utf8mb3_general_ci is set by the my.ini file I put in the <root> folder of the MySQL. If I remove this my.ini file, and restart MySQL again. After that, I try to create a new database, I see the server side default collation is utf8mb4_0900_ai_ci now.

ollydbg23
  • 1,124
  • 1
  • 12
  • 38

1 Answers1

1

It is not necessary to create a my.ini or my.cnf file. Every server option has a compiled-in default. The default values are documented.

utf8_general_ci and utf8_unicode_ci are collations, not encodings.

I recommend using the MySQL 8.0 defaults: character set utf8mb4 and collation utf8mb4_0900_ai_ci unless you have a specific need for something different (if you don't know whether you need something different, then you almost certainly don't).

If you want to know more details, then read the chapter on character sets and collations in the MySQL 8.0 manual: https://dev.mysql.com/doc/refman/8.0/en/charset.html

I would also recommend reading the wikipedia article on UTF-8 for general information: https://en.wikipedia.org/wiki/UTF-8

Also this blog by Stack Overflow co-founder Joel Spolsky: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
  • Hi, Bill, thanks for the answer. I know UTF-8 and other other encoding. But I'm new in the MySQL world, I don't know the "collations". Let me remove my `my.ini`, and try to restart the MySQL again. – ollydbg23 Jun 18 '23 at 05:07
  • A collation is basically how the characters of a given encoding sort. In other words, given a pair of characters in an encoding, are they equal, or which one is less or greater than the other. There are multiple ways to sort characters, because different languages have different standards. Sometimes these standards change, so the general-purpose collation for UTF-8 has to be updated from time to time. The latest revision of the collation for UTF-8 supported by MySQL is named `utf8mb4_0900_ai_ci`. – Bill Karwin Jun 18 '23 at 05:16
  • Thanks, I have just remove `my.ini`, and I see the default collation is `utf8mb4_0900_ai_ci`, I have also updated my question about my finding. – ollydbg23 Jun 18 '23 at 05:19