Making MySQL work with utf-8 in my.cnf configuration file

核能气质少年 提交于 2019-12-08 07:02:28

问题


I'm having troubles trying to change the character sets in MySQL. I'm trying to edit the file "/etc/my.cnf" with the information taken from "http://stackoverflow.com/questions/3513773/change-mysql-default-character-set-to-utf8-in-my-cnf". The problem is, that adding this information to my file (and many others taken from the internet), the MySQL server doesn't start (when rebooting to implement the changes). I get this message:

[root@tribals ~] # /etc/init.d/mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL................................... ERROR!

To be more specific I'll also post the contents of the "my.cnf" file:

[mysql]
default-character-set=utf8

[client]
default-character-set=utf8

[mysqld]
max_connections=200
query_cache_type=1
query_cache_size=2M
query_cache_limit=1M
ft_min_word_len=2
ft_max_word_len=20
ft_stopword_file=''

I'm adding the new content about charsets at the bottom of the file, right after the last line. Here is the code I'm adding:

default-character-set = utf8    
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8

Thanks!

Edit: Hi, here's what the log says:

111111 20:18:00  mysqld started 111111 20:18:00  InnoDB: Started; log sequence number 0 72790
111111 20:18:00 [Warning] './mysql/host' had no or invalid character set, and default character set is multi-byte, so character column sizes may have changed
111111 20:18:00 [Warning] './mysql/user' had no or invalid character set, and default character set is multi-byte, so character column sizes may have changed
111111 20:18:00 [Warning] './mysql/db' had no or invalid character set, and default character set is multi-byte, so character column sizes may have changed
111111 20:18:00 [ERROR] Fatal error: mysql.user table is damaged or in unsupported 3.20 format.
111111 20:18:00  mysqld ended

PD: Sorry, I'm new to this, couldn't find how to do it...


回答1:


Got it!!! Looks like this is a problem when updating MySQL versions, in my case, from 3.2 to 4.1.22. The thing is that the privilege tables must be updated too, but somehow they weren't. So, I logged into the server as root via SSH and executed the command:

mysql_fix_privilege_tables --password=[your_root_pass]

That's it! Hope it helps others in my situation...



来源:https://stackoverflow.com/questions/8086444/making-mysql-work-with-utf-8-in-my-cnf-configuration-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!