MySQL 資料庫優化 詳解

2021-10-14 08:06:56 字數 1387 閱讀 2048

優化:字符集設定

永久配置

設定資料庫最大訪問鏈結是

innodb 資料和索引的記憶體緩衝區

###檢視引擎

mysql> show engines;

mysql> show variables like '%storage_engine%';

mysql> show create table t1;

\\檢視建表資訊

mysql> create table innodb1(id int)engine=innodb;
vim  /etc/my.cnf

[mysqld]

default-storage-engine=innodb

----引擎

mysql> alter table t2 engine=myisam;
看其他的需要看.err日誌

mysql> show warnings;
mysql> show processlist;
mysql> show errors;
給庫設定字符集
mysql> create database db1 character set = utf8;
給表設定字符集
mysql> create table t1(id int(10)) character set = utf8;
# vim /etc/my.cnf

[mysqld]

character_set_server = utf8

# systemctl restart mysql

mysql> show variables like '%query%';
mysql> show variables like '%max_connections%';
# vim /etc/my.cnf

max_connections = 1024

\\併發連線數,根據實際情況設定連線數。

connect_timeout= 5

\\單位秒 ----超時時間,預設30秒

innodb-buffer-pool-size=*

vim /etc/my.cnf

innodb-buffer-pool-size=2g

MySQL資料庫優化方法詳解

一 硬體的優化 1.1 cpu優化 64位cpu,建議多核繫結不同的服務 1.2 記憶體 按照企業發展,合理調控記憶體 1.3 硬碟 數量越多越好,效能 ssd 核心高併發業務 sas 線上普通業務 sata 線下 raid 4 4塊盤 效能 raid0 raid10 raid5 raid1 1.4...

mysql資料庫優化索引 mysql資料庫索引調優

一 mysql索引 1 磁碟檔案結構 innodb引擎 frm格式檔案儲存表結構,ibd格式檔案儲存索引和資料。myisam引擎 frm格式檔案儲存表結構,myi格式檔案儲存索引,myd格式檔案儲存資料 2 mysql資料庫資料範問原理 innodb btree 1 ibd檔案中主鍵構建b tree...

mysql資料庫優先 MySQL資料庫優化

1.新增索引 mysql資料庫的四類索引 index 普通索引,資料可以重複,沒有任何限制。unique 唯一索引,要求索引列的值必須唯一,但允許有空值 如果是組合索引,那麼列值的組合必須唯一。primary key 主鍵索引,是一種特殊的唯一索引,乙個表只能有乙個主鍵,不允許有空值,一般是在建立表...