mysql如何實(shí)現(xiàn)下載安裝配置及編碼設(shè)置

小編給大家分享一下MySQL如何實(shí)現(xiàn)下載安裝配置及編碼設(shè)置,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

創(chuàng)新互聯(lián)建站專注于日喀則企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站,商城網(wǎng)站開(kāi)發(fā)。日喀則網(wǎng)站建設(shè)公司,為日喀則等地區(qū)提供建站服務(wù)。全流程按需設(shè)計(jì)網(wǎng)站,專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)建站專業(yè)和態(tài)度為您提供的服務(wù)

一、下載mysql
             最簡(jiǎn)單方法,直接輸入命令:sudo apt-get install mysql-server。裝完已經(jīng)自動(dòng)配置好環(huán)境變量,可以直接使用mysql的命令。
            下載安裝過(guò)程中會(huì)提示輸入用戶名和密碼,非常easy!

  注:建議將/etc/apt/source.list中的cn改成us,美國(guó)的服務(wù)器比中國(guó)的快很多。

二、配置mysql
      1、啟動(dòng)mysql
      2、在mydql>中輸入:show variables like 'character%';  查看編碼

    +--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

    3、設(shè)置為utf8mb4編碼(生產(chǎn)上多用次編碼)
         a、 控制臺(tái)命令:locate my.cnf   查找mysql配置文件:my.cnf
         b、 編輯 my.cnf 文件如下(紅色為本人改動(dòng)):

[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock
default-character-set = utf8mb4

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock
nice            = 0

[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 0.0.0.0
"/etc/mysql/my.cnf" [readonly] 132L, 3675C   

        4、重啟mysql(非常重要)
        5、測(cè)試配置
          在mydql>中輸入:show variables like 'character%';  查看編碼應(yīng)該如下:

          +--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb4                    |
| character_set_connection | utf8mb4                    |
| character_set_database   | utf8mb4                    |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb4                    |
| character_set_server     | utf8mb4                    |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

四、修改Xshell編碼
        1、修改連接編碼
              xshell中選中要連接的會(huì)話=>右擊選“屬性”=>類別選“終端”=>編碼下拉選“unicodeutf-8”=>確定
        2、修改Xshell工具欄上“編碼”按鈕,選擇“utf8”
五、修改ubuntu編碼
       1、查看服務(wù)器編碼,命令行輸入:locale

LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:zh
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC=zh_CN
LC_TIME=zh_CN
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY=zh_CN
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER=zh_CN
LC_NAME=zh_CN
LC_ADDRESS=zh_CN
LC_TELEPHONE=zh_CN
LC_MEASUREMENT=zh_CN
LC_IDENTIFICATION=zh_CN
LC_ALL=

        2、修改服務(wù)器編碼
             a、使用管理員權(quán)限進(jìn)入/etc/default/
             b、使用vi編輯文件:locale  如下:

            LANG="en_US.UTF-8"
            LANGUAGE="en_US:"
            ~                                                                                                                                                                                  
            ~  

         3、重啟服務(wù)器(虛擬機(jī))
         4、再次查看服務(wù)器編碼、命令行輸入:locale

LANG=en_US.UTF-8
LANGUAGE=en_US:
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

                   全部設(shè)置為utf-8 成功。
        通過(guò)以上五部設(shè)置,所有編碼都設(shè)置為統(tǒng)一utf8,就可以再Xshell中輸入中文,mysql中也可以輸入中文,全部搞定!

看完了這篇文章,相信你對(duì)“mysql如何實(shí)現(xiàn)下載安裝配置及編碼設(shè)置”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

本文題目:mysql如何實(shí)現(xiàn)下載安裝配置及編碼設(shè)置
文章位置:http://muchs.cn/article18/pgdpgp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司自適應(yīng)網(wǎng)站、Google做網(wǎng)站、靜態(tài)網(wǎng)站、App設(shè)計(jì)

廣告

聲明:本網(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)

成都seo排名網(wǎng)站優(yōu)化