使My.cnf配置文件中的MySQL与utf-8一起使用 [英] Making MySQL work with utf-8 in my.cnf configuration file

查看:246
本文介绍了使My.cnf配置文件中的MySQL与utf-8一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试更改MySQL中的字符集时遇到麻烦.我正在尝试使用从"http://stackoverflow.com/questions/3513773/change-mysql-default-character-set-to-utf8-in- my-cnf".问题是,将该信息添加到我的文件(以及许多其他从互联网上获取的信息)后,MySQL服务器无法启动(在重新启动以实现更改时).我收到此消息:

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!

更具体地说,我还将发布"my.cnf"文件的内容:

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

谢谢!

这是日志所说的:

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:对不起,我对此很陌生,找不到解决方法...

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

推荐答案

知道了!!!在我的情况下,将MySQL版本从3.2更新到4.1.22时,这似乎是一个问题.事实是特权表也必须更新,但是不知何故没有更新.因此,我通过SSH以root用户身份登录到服务器,并执行了以下命令:

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

这篇关于使My.cnf配置文件中的MySQL与utf-8一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆