Hi,大家好,我是编程小6,很荣幸遇见你,我把这些年在开发过程中遇到的问题或想法写出来,今天说一说mysql 数据库优化「建议收藏」,希望能够帮助你!!!。
#创建mysql 存储目录
mkdir /data/db/mysql -p
chown mysql.mysql /data/db/mysql/
mysql 优化配置
[client]
port=3306
socket=/var/lib/mysql/mysql.sock
[mysqld]
port=3306
socket=/var/lib/mysql/mysql.sock
datadir=/data/db/mysql
skip-external-locking
character-set-server=utf8
slow_query_log
slow_query_log_file=/var/log/mysql/slowquery.log
long_query_time=2
log-error=/var/log/mysql/log-error.log
skip-name-resolve
max_connections=5000
back_log=300
table-cache=4096
max_allowed_packet=32M
max-heap-table-size=128M
key_buffer_size=128M
sort-buffer-size=16M
join-buffer-size=16M
net_buffer_length=8K
read_buffer_size=256K
read_rnd_buffer_size=512K
myisam_sort_buffer_size=8M
thread-cache-size=16
thread-concurrency=24
query-cache-size=4096M
query-cache-limit=4M
tmp-table-size=128M
log_warnings
innodb_file_per_table=1
innodb_file_io_threads=4
innodb_open_files=2048
innodb_buffer_pool_size=4G
innodb_additional_mem_pool=16M
innodb_thread_concurrency=16
innodb_max_dirty_pages_pct=90
log-bin=mysql-bin
binlog_format=mixed
server-id=1
[mysqldump]
quick
max_allowed_packet=16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size=20M
sort_buffer_size=20M
read_buffer=2M
write_buffer=2M
[mysqlhotcopy]
interactive-timeout