mac的msql字符集修改,却没找着文件
可能你在django会遇到连接数据库时,会不断报错,提醒你安装mysqlclient(事实上你早已安装了),这都是字符集不匹配惹的祸。
1.寻找配置文件
你一开始可能从找配置文件就出了毛病,大家都是在这里:/usr/local/mysql/support-files/
找到my-default.cnf,可你愣是没有。。。
这里八成是安装方式埋下的坑,比如佳酿安装的mysql。自动直接就执行了:
sudo cp /usr/local/mysql/support-files/my-default.cnf /usr/local/etc/my.cnf
这里注意my.cnf不在/etc下😯,在佳酿自己的etc下,所以千万要注意自己的下载方式(下面继续以佳酿为例)
2.修改my.cnf
vim my.cnf
没错,就是这么干净。。
所以想要修改的话,你需要自己搬运一下了。
# Example MySQL config file for small systems.
#
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it's important that the mysqld daemon
# doesn't use much resources.
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
default-character-set=utf8
#password = your_password
port = 3306
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (using the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
server-id = 1
# Uncomment the following if you want to log updates
#log-bin=mysql-bin
# binary logging format - mixed recommended
#binlog_format=mixed
# Causes updates to non-transactional engines using statement format to be
# wri
到这里你就可以参照其他博主和自己要求来改了。
推荐:https://www.cnblogs.com/jie-fang/p/10214207.html