mysql 8.0設置collation_connection

来源:https://www.cnblogs.com/hdwang/archive/2022/09/28/16739147.html
-Advertisement-
Play Games

設置全局 set global collation_connection = utf8mb4_general_ci 設置會話級別 1.配置文件方式,給每個新的連接配置 [mysqld] init-connect='SET NAMES utf8mb4 COLLATE utf8mb4_general_c ...


設置全局

set global collation_connection = utf8mb4_general_ci 

 

設置會話級別

1.配置文件方式,給每個新的連接配置

[mysqld]

init-connect='SET NAMES utf8mb4 COLLATE utf8mb4_general_ci '

2.執行命令

set collation_connection = utf8mb4_general_ci 

SET NAMES utf8mb4 COLLATE utf8mb4_general_ci

 

附錄:

 

 

 

 

 

 

 

 

SQL Statements for Connection Character Set Configuration

After a connection has been established, clients can change the character set and collation system variables for the current session. These variables can be changed individually using SET statements, but two more convenient statements affect the connection-related character set sytem variables as a group:

  • SET NAMES 'charset_name' [COLLATE 'collation_name']

    SET NAMES indicates what character set the client uses to send SQL statements to the server. Thus, SET NAMES 'cp1251' tells the server, future incoming messages from this client are in character set cp1251.” It also specifies the character set that the server should use for sending results back to the client. (For example, it indicates what character set to use for column values if you use a SELECT statement that produces a result set.)

    SET NAMES 'charset_name' statement is equivalent to these three statements:

    SET character_set_client = charset_name;
    SET character_set_results = charset_name;
    SET character_set_connection = charset_name;

    Setting character_set_connection to charset_name also implicitly sets collation_connection to the default collation for charset_name. It is unnecessary to set that collation explicitly. To specify a particular collation to use for collation_connection, add a COLLATE clause:

    SET NAMES 'charset_name' COLLATE 'collation_name'
  • SET CHARACTER SET 'charset_name'

    SET CHARACTER SET is similar to SET NAMES but sets character_set_connection and collation_connection to character_set_database and collation_database (which, as mentioned previously, indicate the character set and collation of the default database).

    SET CHARACTER SET charset_name statement is equivalent to these three statements:

    SET character_set_client = charset_name;
    SET character_set_results = charset_name;
    SET collation_connection = @@collation_database;

    Setting collation_connection also implicitly sets character_set_connection to the character set associated with the collation (equivalent to executing SET character_set_connection = @@character_set_database). It is unnecessary to set character_set_connection explicitly.

Note

Some character sets cannot be used as the client character set. Attempting to use them with SET NAMES or SET CHARACTER SET produces an error. See Impermissible Client Character Sets.

Example: Suppose that column1 is defined as CHAR(5) CHARACTER SET latin2. If you do not say SET NAMES or SET CHARACTER SET, then for SELECT column1 FROM t, the server sends back all the values for column1 using the character set that the client specified when it connected. On the other hand, if you say SET NAMES 'latin1' or SET CHARACTER SET 'latin1' before issuing the SELECT statement, the server converts the latin2 values to latin1 just before sending results back. Conversion may be lossy for characters that are not in both character sets.


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • zip 是一個非常常見的壓縮包格式,本文主要用於說明如何使用代碼 文件或文件夾壓縮為 zip壓縮包及其解壓操作, 我們採用的是 微軟官方的實現,所以也不需要安裝第三方的組件包。 使用的時候記得 using System.IO.Compression; /// <summary> /// 將指定目錄壓 ...
  • 1. 融合效果 融合效果是指對兩個接近的元素進行高斯模糊後再提高對比度,使它們看上去“粘”在一起。在之前的一篇文章中,我使用 Win2D 實現了融合效果,效果如下: 不過 Win2D 不適用於 WPF,在 WPF 中可以使用 BlurEffect 配合自定義 Effect 實現類似的效果。Handy ...
  • 1、初衷 開發中經常需要做一些介面的簽名生成和校驗工作,最開始的時候都是每個介面去按照約定單獨實現,久而久之就變的非常難維護,因此就琢磨怎麼能夠寫了一個比較通用的簽名生成工具。 2、思路 採用鏈式調用的方式,使得簽名的步驟可以動態拼湊組合。 3、直接看效果 //設置數據源 var signSourc ...
  • 在整理 GCC Arm 工具鏈的Bluepill代碼示例, 常用外設都差不多了, 接下來是 FreeRTOS, 網上查到的基本上都是基於舊版本的集成, STM32 SPL版本3.5.0, FreeRTOS版本9.x或者10.x, 不如自己用新版本集成一下. 順便做個筆記. STM32F10x_Std... ...
  • 一、文件目錄類 pwd指令 基本語法:pwd 功能:顯示當前工作的絕對目錄 ls指令 基本語法:ls [選項][目錄或者文件] 常用選項 -a 顯示所有文件及目錄 (. 開頭的隱藏文件也會列出) -l 除文件名稱外,亦將文件型態、許可權、擁有者、文件大小等資訊詳細列出 cd指令 基本語法:cd [參數 ...
  • SourceTree 是 Windows 和Mac OS X 下Git 和 Hg 客戶端管理工具,同時也是Mercurial和Subversion版本控制系統工具,需要的朋友趕快來看看吧! 詳情:SourceTree for Mac(Git客戶端工具) SourceTree Mac是一款針對mac平 ...
  • Haproxy haproxy簡介 HAProxy是一個使用C語言編寫的自由及開放源代碼軟體,其提供高可用性、負載均衡,以及基於TCP和HTTP的應用程式代理。 HAProxy特別適用於那些負載特大的web站點,這些站點通常又需要會話保持或七層處理。HAProxy運行在當前的硬體上,完全可以支持數以 ...
  • 一. 題目: 給如下兩個表,寫一個查詢語句,求出在每一個工資發放日,每個部門的平均工資與公司的平均工資的比較結果 (高 / 低 / 相同)。 工資表:salary | id | employee_id | amount | pay_date | | | | | | | 1 | 1 | 9000 | ...
一周排行
    -Advertisement-
    Play Games
  • 1.1 關於C# C#只是一種簡單安全的新型面向對象語言,繼承了C的語法風格和C++的面向對象特性,不再提供對指針類型的支持(因此程式不可隨便訪問記憶體地址空間)、不再支持多重繼承; C#的誕生意義是生成面向.NET Framework環境的代碼,身為編程語言的一種,它作為開發工具而存在,本身並不是. ...
  • 往一張產品圖片上,加兩個小標簽,Demo實現最好的效果 素材例圖與最終效果如下: 具體實現的代碼如下: 添加引用: using System.Drawing; using System.Drawing.Drawing2D; 註意:如果添加命名空間沒效果,加一下Nuget包 System.Drawin ...
  • 前置要求:有百度賬號,實名認證以及開發者認證,創建應用並獲取到關鍵憑證:Appid、Appkey、Secretkeyk和Signkey 平臺上入門十分清楚,直接對著逐步操作即可,個人開發者審核也很快 百度網盤開放平臺地址如下:https://pan.baidu.com/union/doc/nksg0 ...
  • 使用方法 安裝 Maven <dependency> <groupId>com.github.yulichang</groupId> <artifactId>mybatis-plus-join</artifactId> <version>1.2.4</version> </dependency> G ...
  • 數字常量 int: 一般的整數, long: 長整型,2.x版本需在數字後加 “L” 或 “l” ,表示長整型 如 100000000L; python3.x 版本後不分長整型,統一為int,不可加 “L” 或 “l” float: 浮點數,1.0 也為浮點數,float 可強制轉換為 int,取整 ...
  • if __name__ == "__main__" 也就是說執行當前文件,不調用模塊的時候__name__=__main__ 調用模塊的時候,測試如下: 1、新建 test01.py 文件測試代碼如下 print("這條消息來自test01") def func(): print('hello, w ...
  • 一.scoket基本介紹 1.scoket簡介(以下是來自chatgpt回答) 1)Socket(套接字)是電腦網路中用於描述主機之間通信的一種機制。它定義了一種標準的介面, 使得應用程式可以利用網路傳輸層提供的服務(如TCP或UDP)進行通信。 2)Socket的作用是在網路應用程式之間提供數據 ...
  • 一、函數的定義 可以分為以下兩種: 1、函數聲明和函數定義分離 這種方法將函數聲明和函數定義分開,通常在頭文件中先聲明函數原型,然後在源文件中實現函數定義。 例如,頭文件 example.h 中聲明瞭一個函數 add: #ifndef EXAMPLE_H #define EXAMPLE_H int ...
  • 一 回顧trait使用 https://blog.csdn.net/bushuwei/article/details/103514174發現之前本人說明很模糊,自己居然不知道為什麼其實這裡的$c,就是class B再次回顧邏輯 二 分析 self和static區別說的沒毛病 Trait基類use t ...
  • 一、延遲計算 RDD 代表的是分散式數據形態,因此,RDD 到 RDD 之間的轉換,本質上是數據形態上的轉換(Transformations) 在 RDD 的編程模型中,一共有兩種運算元,Transformations 類運算元和 Actions 類運算元。開發者需要使用 Transformations ...