时间:2021-07-01 10:21:17 帮助过:26人阅读
使用SHOW VARIABLES LIKE ‘character%’;查看,发现数据库编码全已改成utf8。
+--------------------------+----------------------------+
| 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 | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
4、如果上面的都修改了还乱码,那剩下问题就一定在connection连接层上。解决方法是在发送查询前执行一下下面这句(直接写在SQL文件的最前面):SET NAMES ‘utf8‘;
它相当于下面的三句指令:
SET character_set_client = utf8;
SET character_set_results = utf8;
SET character_set_connection = utf8;
网上很多其他方法不能彻底解决这个问题,这个可以完美解决!
附注:MySQL数据库启动,关闭,重启:
开始 sudo /etc/init.d/mysql start
停止 sudo /etc/init.d/mysql stop
重启 sudo /etc/init.d/mysql restart
ubuntu MySQL数据库输入中文乱码 解决方案
标签:编码 文件中 技术 start tar ash .so value init.d