Showing posts with label Mysql utf8. Show all posts
Showing posts with label Mysql utf8. Show all posts

Monday, 24 December 2018

Mysql: Unknown variable default character set utf8 MySQL 5.5 or MariaDB 5.5

If you get an error like “Unknown variable default character set utf8” MySQL or MariaDB 5.5 in /var/log/mariadb/mariadb.log when I restart MySQL database, you can resolve this problem with change variable name.


Error

You can look for error /var/log/mariadb/mariadb.log
/usr/libexec/mysqld: unknown variable ‘default-character-set=utf8’
Aborting


Solution
Find my.cnf file.
[root@testdb ~]# locate my.cnf
/etc/my.cnf
Change parameter name with vi editor. New variable name is character-set-server=utf8
[root@testdb ~]# vi /etc/my.cnf
#default-character-set=utf8
character-set-server=utf8

You can start MySQL or Mariadb database.

[root@testdb ~]# systemctl start mariadb.service

Tuesday, 6 November 2018

What is the difference between utf8mb4 and utf8 charsets in mysql?

What is the difference between utf8mb4 and utf8 charsets in mysql? 
I already know about ASCII, UTF-8, UTF-16 and UTF-32 encodings; but I'm curious to know whats the difference of 'utf8mb4' group of encodings with other encoding types defined in mysql server.
Are there any special benefits/proposes of using utf8mb4 rather than utf8?

 Answers


UTF-8 is a variable-length encoding. In the case of UTF-8, this means that storing one code point requires one to four bytes. However, MySQL's encoding called "utf8" only stores a maximum of three bytes per code point.
So the character set "utf8" cannot store all Unicode code points: it only supports the range 0x000 to 0xFFFF, which is called the "Basic Multilingual Plane". See also Comparison of Unicode encodings.
This is what the MySQL documentation has to say about it:
The character set named utf8 uses a maximum of three bytes per character and contains only BMP characters. As of MySQL 5.5.3, the utf8mb4 character set uses a maximum of four bytes per character supports supplemental characters:
  • For a BMP character, utf8 and utf8mb4 have identical storage characteristics: same code values, same encoding, same length.
  • For a supplementary character, utf8 cannot store the character at all, while utf8mb4 requires four bytes to store it. Since utf8 cannot store the character at all, you do not have any supplementary characters in utf8 columns and you need not worry about converting characters or losing data when upgrading utf8 data from older versions of MySQL.
So if you want your column to support storing characters lying outside the BMP (and you usually want to), such as emoji, use "utf8mb4".