15

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:

Trying to start the server ... Could not re-connect to the MySQL Server. Server could not be started.

Plugin 'FEDERATED' is disabled.

C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld: unknown variable 'default-character-set=utf8'

Aborting

C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld: Shutdown complete

I know that after cancelling the default-character-set, mysql will restart. But if I had to set the default-character-set, is there some other way to make mysql work again?

pja
  • 21
  • 1
  • 7
kaiwii ho
  • 1,317
  • 7
  • 21
  • 39
  • 1
    Did you set this in the config file for mysql? Try character-set-server=utf8 – EO2 Oct 11 '11 at 03:07
  • i have ready try it,but it still post the same prompt and cann't restart yet – kaiwii ho Oct 11 '11 at 03:10
  • 2
    Yes, in the "my.ini". default-character-set is deprecated in 5.5 This link might be of use: http://dev.mysql.com/doc/refman/5.5/en/charset-configuration.html or maybe look for some example configuration files that came with mysql. Already created a db? – EO2 Oct 11 '11 at 03:30
  • yes,i have aready created.I firtstly set it in the mysql 5's administration gui,will it be any compatible mistakens? – kaiwii ho Oct 11 '11 at 03:32
  • And by the way,have u ever used the mysql5.5's workbench before?i want to settd up a new db throgh the restore page,but unfortunately i haven't found any detail about creating a new db using sql file in the restore page.Do u know whre this manufication detail switch to !? – kaiwii ho Oct 11 '11 at 03:35
  • @kaiwiiho: The best way for you is to specify character set when creating a database, e.g. `create database DD default character set utf8`. So you are not dependant on MySQL server settings then. – dma_k Nov 10 '11 at 10:52
  • Also relative answer is [here](http://stackoverflow.com/questions/3513773/change-mysql-default-character-set-to-utf8-in-my-cnf/3513812#3513812). – dma_k Nov 10 '11 at 10:58

3 Answers3

32

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... ;-)

robguinness
  • 15,588
  • 13
  • 53
  • 65
4

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.

Omar Ahmed
  • 41
  • 4
2

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.

elvisef
  • 21
  • 2