歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 在Ubuntu系統中如何解決MySQL在命令行中文亂碼

在Ubuntu系統中如何解決MySQL在命令行中文亂碼

日期:2017/2/28 15:51:56   编辑:Linux教程

1)修改/etc/mysql/my.cnf
sudo gedit /etc/mysql/my.cnf

在my.cnf文件中的[client]段和 [mysqld]段加上以下兩行內容:
[client]
default-character-set=utf8
[mysqld]
default-character-set=utf8

注意是utf8,而不是utf-8:-)

2)重啟mysql服務

sudo service mysql restart

3)登陸並檢查配置

mysql -u root -p

show variables like 'char%";

更多Ubuntu相關信息見Ubuntu 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=2

Copyright © Linux教程網 All Rights Reserved