Home Database Mysql Tutorial mysql 优化变量_MySQL

mysql 优化变量_MySQL

Jun 01, 2016 pm 01:44 PM
mysql optimization

bitsCN.com

 

[mysqld]

port = 3306

server-id = 1 

socket = /tmp/mysql.sock

 

# 避免MySQL的外部锁定,减少出错几率增强稳定性。

skip-locking

 

# 禁止MySQL对外部连接进行DNS解析

skip-name-resolve

 

# 指定MySQL可能的连接数量

back_log = 256

 

# 使用查询缓冲

query_cache_size = 32M

query_cache_type = 1

 

# 指定用于索引的缓冲区大小 对于内存在4GB左右的服务器该参数可设置为256M或384Mkey_reads / key_read_requests 至少是1:100,1:1000更好

key_buffer_size = 256M

 

# 允许的请求包大小一个查询正在执行时,当前查询语句的一份拷贝也需要为之分配内存。

max_allowed_packet = 4M

 

# 指定表高速缓存的大小 对于有1G内存的机器,推荐值是128-256

table_cache = 256K

 

# 查询排序时所能使用的缓冲区大小 每连接独占

sort_buffer_size = 6M

 

# 读查询操作所能使用的缓冲区大小 每连接独占

read_buffer_size = 4M

 

# 联合查询操作所能使用的缓冲区大小 每连接独占

join_buffer_size = 8M

 

#MyISAM表发生变化时重新排序所需的缓冲

myisam_sort_buffer_size = 64M

 

# 指定MySQL查询缓冲区的大小

query_cache_size = 64M

 

tmp_table_size = 256M

 

# 指定MySQL允许的最大连接进程数

max_connections = 768

 

max_connect_errors = 10000000

 

# 指定一个请求的最大连接时间

wait_timeout = 10

interactive_timeout =10

 

# 该参数取值为服务器逻辑CPU数量×2

thread_concurrency = 8

 

# 缓存可重用的线程数

thread_cache = 256

thread_cache_size = 64

 

# 每个线程的栈大小

thread_stack = 256K

 

#记录慢查询,然后对慢查询一一优化

log-slow-queries = slow.log

long_query_time = 2

log-queries-not-using-indexes

 

#关闭不需要的表类型,如果你需要,就不要加上这个

skip-innodb

skip-bdb

 

#设置默认创建的表是InnoDB 类型

default-table-type = innodb

 

#innodb主目录

innodb_data_home_dir = /mysql_data

 

#控制分配给对Innodb内部数据字典进行排序所需的缓冲。

innodb_additional_mem_pool_size = 50M

 

#innodb指定数据文件名及大小

innodb_data_file_path = ibdata1:20G;ibdata2:200M:autoextend

 

#设置缓冲池的大小为你的主内存大小的50 - 80 %

innodb_buffer_pool_size = 70M

 

#设置日志文件的大小约为缓冲池(buffer pool)大小的25 %

innodb_log_file_size = 20M

 

#InnoDB 将日志写入日志磁盘文件前的缓冲大小

innodb_log_buffer_size = 4M 

 

#意味着在事务提交前日志已被写入磁盘, 事务可以运行更长以及服务崩溃后的修复能力

innodb_flush_log_at_trx_commit = 1

bitsCN.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to insert data into a MySQL table using PHP? How to insert data into a MySQL table using PHP? Jun 02, 2024 pm 02:26 PM

How to insert data into MySQL table? Connect to the database: Use mysqli to establish a connection to the database. Prepare the SQL query: Write an INSERT statement to specify the columns and values ​​to be inserted. Execute query: Use the query() method to execute the insertion query. If successful, a confirmation message will be output.

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

How to use MySQL stored procedures in PHP? How to use MySQL stored procedures in PHP? Jun 02, 2024 pm 02:13 PM

To use MySQL stored procedures in PHP: Use PDO or the MySQLi extension to connect to a MySQL database. Prepare the statement to call the stored procedure. Execute the stored procedure. Process the result set (if the stored procedure returns results). Close the database connection.

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.

C++ program optimization: time complexity reduction techniques C++ program optimization: time complexity reduction techniques Jun 01, 2024 am 11:19 AM

Time complexity measures the execution time of an algorithm relative to the size of the input. Tips for reducing the time complexity of C++ programs include: choosing appropriate containers (such as vector, list) to optimize data storage and management. Utilize efficient algorithms such as quick sort to reduce computation time. Eliminate multiple operations to reduce double counting. Use conditional branches to avoid unnecessary calculations. Optimize linear search by using faster algorithms such as binary search.

The difference between oracle database and mysql The difference between oracle database and mysql May 10, 2024 am 01:54 AM

Oracle database and MySQL are both databases based on the relational model, but Oracle is superior in terms of compatibility, scalability, data types and security; while MySQL focuses on speed and flexibility and is more suitable for small to medium-sized data sets. . ① Oracle provides a wide range of data types, ② provides advanced security features, ③ is suitable for enterprise-level applications; ① MySQL supports NoSQL data types, ② has fewer security measures, and ③ is suitable for small to medium-sized applications.

See all articles