mysql 5.7.13的字符集怎么修改

mysql 5.7.13的字符集怎么修改,第1张

通过 SHOW VARIABLES LIKE 'character_set_%'查看mysql字符集情况

[sql] view plain copy

mysql>show variables like "%char%"

+--------------------------+---------------+

| Variable_name | Value |

+--------------------------+---------------+

| character_set_client | utf8 |

| character_set_connection | utf8 |

| character_set_database | utf8 |

| character_set_filesystem | binary |

| character_set_results | utf8 |

| character_set_server | latin1 |

| character_set_system | utf8 |

+--------------------------+-------------+

2、日狗的 latin1 是很多语言乱码的主要原因,通过修改my.cnf 的方法,一劳永逸的解决乱码问题,两处修改的地方

不知道 my.cnf 文件在哪里,可以使用 whereis my.cnf 命令查找

[sql] view plain copy

# 修改处1:添加以下2行

[client]

default-character-set=utf8

[mysqld]

#skip-grant-tables

#skip-networking

#

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M

#

# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

# log_bin

#

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

# 修改处2:添加以下3行

default-storage-engine=INNODB

character-set-server=utf8

collation-server=utf8_general_ci

(1) 最简单的修改方法,就是修改mysql的my.ini文件中的字符集键值,

如 default-character-set = utf8 character_set_server = utf8

修改完后,重启mysql的服务,service mysql restart

使用 mysql>SHOW VARIABLES LIKE 'character%'查看,发现数据库编码均已改成utf8

(2) 还有一种修改mysql默认字符集的方法,就是使用mysql的命令


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/6111222.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-15
下一篇 2023-03-15

发表评论

登录后才能评论

评论列表(0条)

保存