navicat for mysql 顯示中文亂碼解決辦法
最近遇到一個問題,用navicat for mysql 打開數據庫時全都顯示的是亂碼(在用程序代碼插入數據之前確保字符不是亂碼),遇到問題就的尋求解決之道,百度了好長時間也沒解決,網上那些解決辦法都不適合我的問題,網上的大多數解決方法是在navicat里右擊一個連接,選擇連接屬性,切換到高級選項卡,去掉“使用mysql字符集”前的對勾,在編碼里選擇utf-8,這種方法對於部分問題可能適合,但是我的亂碼問題依然存在,於是乎我又將utf-8改稱gbk,gb2312,全都過問題依然粹依舊。
后來跟一個編程的老程序員請教了一下,他說可能是mysql的配置文件有問題,就是在mysql 的安裝目錄下的my.ini文件里的默認編碼有問題,將my.ini文件的這兩處的默認編碼
==========================================
[mysql]
default-character-set=utf8 <------
==========================================
[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3306
#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 5.0/"
#Path to the database root
datadir="C:/Program Files/MySQL/MySQL Server 5.0/Data/"
# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=utf8 <------
===========================================
箭頭所指的地方確保為utf8(注意不是utf-8),navicat 里的使用的是mysql字符集(此時不用再選擇utf-8編碼), 問題才得以解決!我熟悉的中文字符又回來了!哪位朋友要使遇到同樣的問題,希望能幫幫上忙。
后來跟一個編程的老程序員請教了一下,他說可能是mysql的配置文件有問題,就是在mysql 的安裝目錄下的my.ini文件里的默認編碼有問題,將my.ini文件的這兩處的默認編碼
==========================================
[mysql]
default-character-set=utf8 <------
==========================================
[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3306
#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 5.0/"
#Path to the database root
datadir="C:/Program Files/MySQL/MySQL Server 5.0/Data/"
# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=utf8 <------
===========================================
箭頭所指的地方確保為utf8(注意不是utf-8),navicat 里的使用的是mysql字符集(此時不用再選擇utf-8編碼), 問題才得以解決!我熟悉的中文字符又回來了!哪位朋友要使遇到同樣的問題,希望能幫幫上忙。