您好,登錄后才能下訂單哦!
小編給大家分享一下mysql如何實現下載安裝配置及編碼設置,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
一、下載mysql
最簡單方法,直接輸入命令:sudo apt-get install mysql-server。裝完已經自動配置好環境變量,可以直接使用mysql的命令。
下載安裝過程中會提示輸入用戶名和密碼,非常easy!
注:建議將/etc/apt/source.list中的cn改成us,美國的服務器比中國的快很多。
二、配置mysql
1、啟動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、設置為utf8mb4編碼(生產上多用次編碼)
a、 控制臺命令:locate my.cnf 查找mysql配置文件:my.cnf
b、 編輯 my.cnf 文件如下(紅色為本人改動):
[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、測試配置
在mydql>中輸入:show variables like 'character%'; 查看編碼應該如下:
+--------------------------+----------------------------+
| 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中選中要連接的會話=>右擊選“屬性”=>類別選“終端”=>編碼下拉選“unicodeutf-8”=>確定
2、修改Xshell工具欄上“編碼”按鈕,選擇“utf8”
五、修改ubuntu編碼
1、查看服務器編碼,命令行輸入: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、修改服務器編碼
a、使用管理員權限進入/etc/default/
b、使用vi編輯文件:locale 如下:
LANG="en_US.UTF-8"
LANGUAGE="en_US:"
~
~
3、重啟服務器(虛擬機)
4、再次查看服務器編碼、命令行輸入: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=
全部設置為utf-8 成功。
通過以上五部設置,所有編碼都設置為統一utf8,就可以再Xshell中輸入中文,mysql中也可以輸入中文,全部搞定!
看完了這篇文章,相信你對“mysql如何實現下載安裝配置及編碼設置”有了一定的了解,如果想了解更多相關知識,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。