[MDEV-6556] Please, add information how to change the default character set and collation into utf8! Created: 2014-08-08  Updated: 2014-09-04  Resolved: 2014-09-04

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: N/A
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: TImur Fayzrakhmanov Assignee: Ian Gilfillan
Resolution: Fixed Votes: 1
Labels: documentation
Environment:

Ubuntu Server 14.04, MariaDB 10.1.0


Attachments: PNG File problem.png    

 Description   

I'm sorry for the mistakes I've made - I'm from Russia.
May be it is not right place to post this issue but still. The problem is that many people (personally know two people besides me) face the problem of changing the default character set from latin1 to utf8.
The most popular resource for solving this problem is http://stackoverflow.com/questions/3513773/change-mysql-default-character-set-to-utf-8-in-my-cnf.

As a result: I still can't find the right way to make my mysql service using utf8 character set.

Could anybody give the solution that will really work!?
I attached the screenshot of my server where mysql/my.cnf on left side and the result on right side.



 Comments   
Comment by Elena Stepanova [ 2014-08-08 ]

Hi Timur,

The highest-ranking answer from the link above is correct. In your case, you are missing

[mysql]
default-character-set=utf8

and in case you need it for some other clients,

[client]
default-character-set=utf8

Comment by TImur Fayzrakhmanov [ 2014-08-08 ]

The result of code above is:

/var/log/mysql/error.log:
...
[ERROR] /usr/sbin/mysqld: unknown variable 'default-character-set=utf8'
...

So mysql service starting is fail:

* Starting MariaDB database server mysqld                             [ fail ]

Comment by Elena Stepanova [ 2014-08-08 ]

Timur,

Please note the example above: it must be mysql section, not mysqld section.

Please provide a screenshot of your new cnf.

Comment by TImur Fayzrakhmanov [ 2014-08-08 ]

Thank you for elaboration. I've updated my configuration, but the result is not full utf8:

> SHOW VARIABLES like '%char%';
 
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

Comment by Elena Stepanova [ 2014-08-08 ]

You already had character_set_server = utf8 earlier, what's changed?
If you removed charater-set-server from your mysqld section (last visible line on the screenshot), you didn't need to do it. Once again, note the example above – those were additions, things that you were missing in your cnf. mysqld section should remain the same as it was.

Comment by TImur Fayzrakhmanov [ 2014-08-08 ]

Good, now it works!
However, before I've wrote the issue I find the another solution:

[mysqld]
skip-character-set-client-handshake
character_set_client = utf8
character_set_server = utf8

The code above works the same. Is it correct?

Ok, I hardly find the solution. Sometimes I think that configuration file is the real mess: some options have names like option_name_foo and other option-name-bar.
One more point, I've tried to find configuration's options under client or mysql sections in official documentation but get nothing. Is it so obvious that under these section there are options like default-character-set=utf8?

Comment by TImur Fayzrakhmanov [ 2014-08-08 ]

It seems like official documentation has no information about default-character-set option..
http://goo.gl/k21Mvn

Comment by Elena Stepanova [ 2014-08-08 ]

The code above works the same. Is it correct?

For your goal, and given that no clients specify the option explicitly, yes, it will be the same.
You can even keep all 3 of them (I mean character_set_client in mysqld section and default-character-set in mysql/client section, they are not mutually exclusive. skip-character-set-client-handshake disables the latter two).

It seems like official documentation has no information about default-character-set option..
http://goo.gl/k21Mvn

Apparently it doesn't get a high rank from google, but here it is:
https://mariadb.com/kb/en/mariadb/documentation/clients-and-utilities/mysql-client/mysql-command-line-client/

Sometimes I think that configuration file is the real mess: some options have names like option_name_foo and other option-name-bar.

Usually it's just a matter of different preferences of example writers. Pretty much all options can be written either way. Variables always have underscores.

One more point, I've tried to find configuration's options under client or mysql sections in official documentation but get nothing. Is it so obvious that under these section there are options like default-character-set=utf8?

You need to look for client documentation, not server documentation. There is plenty of it in MySQL manual, and you can find some in MariaDB KB, too (see the link above for example).

Comment by TImur Fayzrakhmanov [ 2014-08-09 ]

Thank you for your explanations. They are really helpful.
Be that as it may, if I didn't ask the question I would never guessed the right way of doing it. From my opinion, you shouldn't deny that solution isn't obvious. If it was so obvious then there is no so many question about that.

Thus I think information how to change character set must be transparent and should be specified in documentation, for example here: https://mariadb.com/kb/en/mariadb/documentation/data-types/string-data-types/data-types-character-sets-and-collations/setting-character-sets-and-collations/

Why it so bother me? If I have no information how to change the only character set, what be in the future if I need something more complicated?

Comment by Elena Stepanova [ 2014-08-09 ]

I do agree that it's reasonable to have it on this page https://mariadb.com/kb/en/mariadb/documentation/data-types/string-data-types/data-types-character-sets-and-collations/setting-character-sets-and-collations

Assigning to Ian.

Comment by TImur Fayzrakhmanov [ 2014-08-09 ]

Good! Thank you again Elena!
Спасибо Лен) Какой раз уже сталкиваюсь с тем что приходится со своими на англ разговаривать - вот тебе и globalization!

Comment by Ian Gilfillan [ 2014-09-04 ]

I have added this as an example to the documentation

Generated at Thu Feb 08 07:12:49 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.