默认的 mysql编码 不是utf8 因此想到要改成utf8 以支持中文
my.cnf 这个配置文件如果为空或不存在的时候mysql采用默认配置运行,这个没有多大关系。 如果你需要做相关配置则可以拷贝任意一个配置文件到/etc目录下,然后根据你的实际需要进行修改就可以了。
my.cnf配置文件在网上可以搜到很多的,你随便复制一个然后添加到你的服务器上就可以了但是却找不到配置文件 去网上找了好久才看到这个问题 http://bbs.csdn.net/topics/391966286 三楼的解决措施是对的 记录一下
问题:
可能也不是找不到 有下面的这个配置文件
/etc/mysq/my.cnf
内容是这样的。我如何找到啊。
我想改类似编码之类的如何改。。。求助。
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
进入上述的两个目录拳打开也没有类似网上找的的配置文件类似的文档
这个是Ubuntu16.04 直接在软件源上安装的
解决:
1.
sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf
2.在[mysqld]在下方添加以下代码
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
3.重启mysql服务
sudo service mysql restart
4.检测字符集是否更新成utf8.
进入mysql,mysql -u root -p,输入show variables like '%character%' 查看字符集