How to set the default character-set?

前端 未结 3 1762
后悔当初
后悔当初 2020-12-20 12:30

I want to create a new db in mysql. I set utf8 as the default-character-set, but when I attempted to restart the db, mysql failed to restart and posted the following prompt:

相关标签:
3条回答
  • 2020-12-20 12:37

    I had a similar problem when running mysqlslap i get the following error:

    mysqlslap unknown variable 'default-character-set=utf8mb4'
    

    After a lot of investigations i discovered that default-character-set was being set in another file instead of all the config files i changed.

    The option was set in /etc/mysql/mariadb.conf.d/50-client.cnf, so i just commented this line default-character-set = utf8mb4 and everything went well.

    I have MySQL running on Debian 9. that in case someone is having the same problem.

    0 讨论(0)
  • 2020-12-20 12:40

    Had the same issue today, but with version 5.7.31. For me commenting the line did work but.. how to set the character set in config files then ?

    There's a reply: https://dev.mysql.com/doc/refman/5.7/en/charset-applications.html

    So, to specify character settings at server startup we can for example add these lines in two files (for me these were: 50-client.cnf and 50-mysql-clients.cnf - both in /etc/mysql/mariadb.conf.d/ directory):

    [mysqld]
    character-set-server=utf8
    collation-server=utf8_general_ci
    

    Remember about the "mysqld" section, it is important, because in the "client" section this won't work.

    0 讨论(0)
  • 2020-12-20 12:42

    I had a similar problem. The answer, as EO2 pointed out, is that default-character-set is deprecated in 5.5. You should use instead:

    character-set-server = utf8
    

    BTW, it's better if answers are answered as answers, not comments... ;-)

    0 讨论(0)
提交回复
热议问题