本篇內(nèi)容主要講解“mysql服務(wù)端編碼的設(shè)置”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“mysql服務(wù)端編碼的設(shè)置”吧!
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、微信小程序開發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了海口免費(fèi)建站歡迎大家使用!安裝完,啟動(dòng)后發(fā)現(xiàn)服務(wù)器默認(rèn)使用的是lat1編碼.
具體操作和查看過(guò)程如下:
啟動(dòng)方式: /etc/init.d/mysql.server start
效果:
Database changed
mysql> status
--------------
mysql Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86_64) using readline 5.1
Connection id: 8
Current database: demodb
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.5.21 MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: utf8
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 33 sec
Threads: 7 Questions: 137 Slow queries: 0 Opens: 83 Flush tables: 1 Open tables: 76 Queries per second avg: 4.151
--------------
mysql>
啟動(dòng)方式: /etc/init.d/mysql.server start --character-set-server=utf8
效果:
mysql> use demodb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> status;
--------------
mysql Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86_64) using readline 5.1
Connection id: 4
Current database: demodb
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.5.21 MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 1 min 15 sec
Threads: 4 Questions: 131 Slow queries: 0 Opens: 84 Flush tables: 1 Open tables: 77 Queries per second avg: 1.746
--------------
mysql>
這種方式,在每次啟動(dòng)的時(shí)候都需要指定編碼參數(shù).否則服務(wù)器就使用的是系統(tǒng)默認(rèn)的lat1編碼.
另外一種方法是:
mysql>set character_set_server=utf8;
這種方法我也試了,不行,再重新登錄客戶端后,就又恢復(fù)了原來(lái)的編碼.理由很簡(jiǎn)單,系統(tǒng)啟動(dòng)的時(shí)候用的不是utf8編碼.
一勞永逸的辦法,就是通過(guò)修改配置文件實(shí)現(xiàn).
# vim /etc/my.cnf
內(nèi)容如下:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
#添加下面的紅字內(nèi)容
character-set-server=utf8
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
到此,相信大家對(duì)“mysql服務(wù)端編碼的設(shè)置”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)建站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
分享文章:mysql服務(wù)端編碼的設(shè)置-創(chuàng)新互聯(lián)
標(biāo)題鏈接:http://vcdvsql.cn/article2/diohic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營(yíng)銷型網(wǎng)站建設(shè)、關(guān)鍵詞優(yōu)化、用戶體驗(yàn)、網(wǎng)站導(dǎo)航、小程序開發(fā)、自適應(yīng)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容