mysql utf8 my.cnf,在my.cnf配置文件中使MySQL与utf-8一起使用

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

解决方案

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值