如果使用的是MySQL 5.0.x
可以直接將以下內容保存替換MySQL中的my.ini,記得要修改basedir和datadir兩個欄目的路徑。
復制代碼 代碼如下:
[client]
port=3306
[mysql]
default-character-set=gbk
[mysqld]
port=3306
basedir="D:/web/mysql/"
datadir="D:/web/mysql/Data/"
default-character-set=gbk
default-storage-engine=MYISAM
max_connections=1910
query_cache_limit=2M
query_cache_size=64M
query_cache_type=1
table_cache=64
tmp_table_size=32M
thread_cache_size=64
myisam_sort_buffer_size=8M
key_buffer_size=256M
read_buffer_size=64K
read_rnd_buffer_size=256K
sort_buffer_size=208K
skip-bdb
back_log=500
skip-locking
skip-innodb
thread_concurrency=16
max_connect_errors=30000
wait_timeout=120
max_allowed_packet=2M
interactive_timeout=120
local-infile = 0
復制代碼 代碼如下:
#Enter a name for the error log file. Otherwise a default name will be used.
#log-error=
#Enter a name for the query log file. Otherwise a default name will be used.
#log=
#Enter a name for the slow query log file. Otherwise a default name will be used.
#log-slow-queries= log-slow-queries.txt
#Enter a name for the update log file. Otherwise a default name will be used.
#log-update=
#Enter a name for the binary log. Otherwise a default name will be used.
#log-bin=
復制代碼 代碼如下:
# Minimum word length to be indexed by the full text search index.
# You might wish to decrease it if you need to search for shorter words.
# Note that you need to rebuild your FULLTEXT index, after you have
# modified this value.
ft_min_word_len = 1
為什么要用全文索引呢?
一般的數據庫搜索都是用的SQL的like語句,like語句是不能利用索引的,每次查詢都是從第一條遍歷至最后一條,查詢效率極其低下。一般數據超過10萬或者在線人數過多,like查詢都會導致數據庫崩潰。這也就是為什么很多程序都只提供標題搜索的原因了,因為如果搜索內容,那就更慢了,幾萬數據就跑不動了。
MySQL全文索引是專門為了解決模糊查詢提供的,可以對整篇文章預先按照詞進行索引,搜索效率高,能夠支持百萬級的數據檢索。
如果您使用的是自己的服務器,請馬上進行設置,不要浪費了這個功能。
如果您使用的是虛擬主機,請馬上聯系空間商修改配置。首先,MySQL的這個默認值對于中文來說就是一個錯誤的設置,修改設置等于糾正了錯誤。其次,這個配置修改很簡單,也就是幾分鐘的事情,而且搜索效率提高也降低了空間商數據庫宕掉的幾率。如果你把本篇文章發給空間商,我相信絕大部分都會愿意改的。
特別注意:無論做以上哪一項修改后都必須重啟MySQL服務使修改生效。
重啟方法
方法一:在開始-運行輸入:net stop mysql 回車,再在運行輸入:net start mysql 回車。
方法二:或者開始-控制面板-管理工具-服務,然后找到 MySQL這一項點擊右鍵,選擇重啟服務。
新聞熱點
疑難解答