ubuntu下mysql出现中文乱码怎么办
解决方法如下:
(推荐教程:mysql数据库学习教程)
1、以root用户登录,在终端输入命令
sudo gedit /etc/mysql/my.cnf
在打开的文件中找到[client] 在下面加入
default-character-set=utf8
2、找到 [mysqld_safe]在下面加入
default-character-set=utf8
3、找到[mysqld]在下面加入,12.04以后
character-set-server=utf8init_connect='SET NAMES utf8'
或者12.04以前
default-character-set=utf8init_connect='SET NAMES utf8'
4、找到[mysql]在下面加入
default-character-set=utf8
5、重启mysql命令以便让你上面的修改生效
停用命令:
sudo mysqladmin shutdown -u root -p
启用命令:
sudo /etc/init.d/mysql restart
6、查看现在mysql的编码
进入mysql命令:
sudo mysql -u root -p
检查mysql字符集命令:
show variables like 'character%';+--------------------------+----------------------------+
| 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/ |
+--------------------------+----------------------------
以上是 ubuntu下mysql出现中文乱码怎么办 的全部内容, 来源链接: utcz.com/z/539277.html