MySQL 資料庫
在Linux環境下登入
使用root
帳號登入
使用fooUser
帳號登入44.55.66.77
的Database
檢查編碼
What is the (default) charset for:
- MySQL database
- MySQL table
- MySQL column
To see default collation of the database:
To see collation of the table:
查看全部COLUMN的資訊
示意圖
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
查看建表的指令
參考
更改時區指令
/*!40103 SET TIME_ZONE='+08:00' */;
此指令為時區+8
MYSQL 8 預設table AI可能發生碰撞
innodb_autoinc_lock_mode 變量 有三種可能的設置 。設置為 0、1 或 2,分別表示 “傳統”、“連續”或 “交錯”鎖定模式。從 MySQL 8.0 開始,交錯鎖模式 ( innodb_autoinc_lock_mode=2) 是默認設置。在 MySQL 8.0 之前,連續鎖定模式是默認的 ( innodb_autoinc_lock_mode=1)。
所以調整設定成innodb_autoinc_lock_mode=1
即可
需要restart
Blob資料轉移錯誤
因:轉移DB 和目標DB不同
將mariaDB轉為mysql後則正常匯入
DB轉換參考
Table 資料表無痛轉移
- 鎖定要轉移的資料表
- 更名資料表
- 解鎖資料表
匯出資料表成.gz壓縮檔
參考
參考2
參考3
Query 紀錄
紀錄所有SQL Query紀錄
P.S. 此方式會產生大量資料 注意硬碟空間並使用
先確認紀錄方式
結果如下
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
or
成功畫面如下
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
接著開啟General log
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
之後就可以select mysql.general_log 這張表或者是在檔案中查詢了
可以再次確認紀錄方式
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
因為general log的量很大(所有connections的所有Query),所以要不要常態開啟需要自行評估一下
參考
Slow Query
https://www.opencli.com/mysql/mysql-slow-query-log