linux mysql 中文乱码的问题

本文介绍如何通过修改MySQL配置文件my.cnf来将默认字符集设置为UTF8,包括具体的配置项如collation-server、init-connect和character-set-server等,并提供了验证设置是否生效的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

搜索了不少资料,都不起作用,还是stackoverflow上的一位老兄的建议解决了我的问题,见:http://stackoverflow.com/questions/3513773/change-mysql-default-character-set-to-utf8-in-my-cnf

在上面网址对应的页面中,有图有真相;

我就摘抄几行:

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Then your configuration file ('/etc/my.cnf' for example) should look like that:(但是不一定就是在/etc/my.cnf这个目录里,我的就是/etc/mysql/my.cnf文件)

  1. Remove that directive and you should be good.

  2. Then your configuration file ('/etc/my.cnf' for example) should look like that:

    [mysqld]
    collation-server = utf8_unicode_ci
    init-connect='SET NAMES utf8'
    character-set-server = utf8
  3. Restart MySQL.

  4. For making sure, your MySQL is UTF8, Run the following queries in your MySQL prompt:

    • First query:

       mysql> show variables like'char%';
以下内容见http://stackoverflow.com/questions/3513773/change-mysql-default-character-set-to-utf8-in-my-cnf,粘贴复制也是很麻烦的


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值