如何彻底解决MySQL更改默认字符集以及字符乱码问题!!!
2024-08-24 16:55:13
在我们使用MySQL数据库时,字符乱码,对我们来说是一个很头疼的问题。今天笔者就来教大家如何彻底解决更改默认字符集以及字符乱码问题。
当我们使用压缩包进行MySQL安装后,系统会使用默认的字符集,这时就会产生乱码。
方案:
来到MySQL安装路径下,创建一个my.ini文件(如果有my-default.ini文件,则改为my.ini),打开my.ini,将里面的内容做如下更改(复制粘贴到文件内就可以):
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] # 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 # These are commonly set, remove the # and set as required. basedir = 此处为你的安装路径 (例:D:\mysql) datadir = 此处为你的安装路径(例:D:\mysql\data) port = 3306 # server_id = mysql character_set_server = utf8 # 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 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [client] port = 3306 default-character-set = utf8
其中路径一定不能错,不然会无法启动MySQL服务。
此配置启用需要重启MySQL服务。
此时通过管理员运行的CMD,停止MySQL服务:net stop mysql。
接着输入:net start mysql
此时,用root进入MySQL数据库(mysql -u root -p),输入show variables like 'char%'; 查看字符集设置。
至此,MySQL的字符集修改以及乱码问题就解决了。。。
最新文章
- CozyRSS开发记录4-抽屉效果订阅列表栏
- SQL Server 2014里的针对基数估计的新设计(New Design for Cardinality Estimation)
- umask 权限设置文章
- Greenplum failed segment的恢复方法
- jsp多条件查询及查询结果在同一页面显示(原创)
- 常用Raspberry Pi周边传感器的使用教程
- 穿透的 div ( pointer-events )
- 利用命令行来安装应用到android虚拟机
- Fraction to Recurring Decimal leetcode
- Spring - Spring容器概念及其初始化过程
- Spring 框架系列之 JDBC 整合实例
- CSS3文字、背景与列表
- B2C商城关键技术点总结(站内搜索、定时任务)
- Java探针-Java Agent技术-阿里面试题
- py4CV例子3Mnist识别和ANN
- influxDB1.6版安装与配置(windows环境)、Jmeter+influxDB+Grafana性能监控
- 【Noip模拟 20161005】公约数
- leetcode338—Counting Bits
- python3获取主机名、主机IP
- LA3905
热门文章
- Day3---------Linux操作系统目录结构
- linux -->; Linux变量之$#, $*, $@含义
- 源码实现 -->; atoi函数实现
- APP专业的开发公司都有这样一套开发流程,强烈建议收藏!
- diy51单片机最小系统------从零件到51整体测试成功小白篇
- [bzoj1707]tanning分配防晒霜_贪心+排序
- Wannafly交流赛1(施工中)
- 按指定id顺序查询
- 201621123040《Java程序设计》第九周学习总结
- 冲刺NO.8