mysql my.ini 日志_浅析Mysql的my.ini文件

2023-05-16

转载:http://hunanpengdake.iteye.com/admin/blogs/1647725今天闲的蛋疼,没事想了解mysql,大家都知道在配置Mysql的过程中,my.ini非常重要,一直对其深感迷惑,那么鼓起勇气,看看mysql的 my.ini的真实面目(小弟E文一直很差,有错误的地方请各位指出):

第一步,我们找到mysql安装文件下面的my.ini文件,打开可以看到第一句:

# MySQL Server Instance Configuration File

Mysql服务实例配置文件

好,咱们撇开那些不是那么重要的字幕,直接进入重点,看看它可以配置些什么,和到底配置了些什么,那么带着这样的心态,我们往下看。CLIENT SECTION

客户端章节:[client]port=3306            端口号=3306[mysql]default-character-set=latin1    默认字符编码=latin1SERVER SECTION

服务端章节[mysqld]# The TCP/IP Port the MySQL Server will listen onTCP/IP Port 监听mysql的端口号port=3306#Path to installation directory. All paths are usually resolved relative to this.安装目录路径 。所有的路径都是作为这个路径的相对路径。basedir="E:/programfile/MySql5.1/"#Path to the database root数据库数据的根路径datadir="C:/ProgramData/MySQL/MySQL Server 5.1/Data/"# The default character set that will be used when a new schema or table is# created and no character set is defined默认的字符集编码作用于当一个新的schema 或者表被创建的时候没有指定字符集。default-character-set=latin1# The default storage engine that will be used when create new tables when默认的存储引擎作用于当创建新表的时候default-storage-engine=INNODB# Set the SQL mode to strict设置严格的SQL模型sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"# The maximum amount of concurrent sessions the MySQL server will# allow. One of these connections will be reserved for a user with# SUPER privileges to allow the administrator to login even if the# connection limit has been reached.Mysql 服务端允许最大的并发数,其中一个连接将留给用户使用超级权限连接数据库,即使连接数已经达到最高限额max_connections=100# Query cache is used to cache SELECT results and later return them# without actual executing the same query once again. Having the query# cache enabled may result in significant speed improvements, if your# have a lot of identical queries and rarely changing tables. See the# "Qcache_lowmem_prunes" status variable to check if the current value# is high enough for your load.# Note: In case your tables change very often or if your queries are# textually different every time, the query cache may result in a# slowdown instead of a performance improvement.查询缓存用于在缓存中SELECT结果,返回不是实际查询数据库的结果。

从缓存中查询的结果会显著的提升查询速度,如果你有很多相同的查询和很少改变表结构。

查看“Qcache_lowmem_prunes”状态变量来检查当前值对于你的负载是否足够高。

NOTE:如果你的表结构经常改变或者,你每次查询都不相同,那么使用查询缓存结果可能不是一个性能改进。query_cache_size=15M# The number of open tables for all threads. Increasing this value# increases the number of file descriptors that mysqld requires.# Therefore you have to make sure to set the amount of open files# allowed to at least 4096 in the variable "open-files-limit" in# section [mysqld_safe]所有的线程打开表的数量。table_cache=256# Maximum size for internal (in-memory) temporary tables. If a table# grows larger than this value, it is automatically converted to disk# based table This limitation is for a single table. There can be many# of them.临时表最大内存大小。如果一个表生长大于这个值,它会自动转换为磁盘,这只是限制单个表,可以有很多个tmp_table_size=18M# How many threads we should keep in a cache for reuse. When a client# disconnects, the client's threads are put in the cache if there aren't# more than thread_cache_size threads from before.  This greatly reduces# the amount of thread creations needed if you have a lot of new# connections. (Normally this doesn't give a notable performance# improvement if you have a good thread implementation.)有很多线程我们应该保持在一个缓存里以便重用。在没有超过超过线程缓存大小之前,当一个客户端断开连接时,把客户端线程放在缓存中。如果你有很多新的连接,那么这大大降低了线程的数量创造需要。(如果你有一个好的改进线程实现方案,那么这个并不会给出一个显著的性能)thread_cache_size=8#*** MyISAM Specific options

MYISAM 特殊配置项# The maximum size of the temporary file MySQL is allowed to use while# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE.# If the file-size would be bigger than this, the index will be created# through the key cache (which is slower).Mysql临时文件允许使用重建索引(在修复,修改表结构,导入数据文件时)的最大大小。

如果文件大小会比这个大,该指数将被创建通过键缓存(很慢)myisam_max_sort_file_size=100G# If the temporary file used for fast index creation would be bigger# than using the key cache by the amount specified here, then prefer the# key cache method.  This is mainly used to force long character keys in# large tables to use the slower key cache method to create the index.如果临时文件用于快速创建索引将比使用键缓存更大,那么键缓存的方法是很好的。这主要用于在比较大型的表使用缓慢的基础上,使用长字符串创建索引。myisam_sort_buffer_size=35M# Size of the Key Buffer, used to cache index blocks for MyISAM tables.# Do not set it larger than 30% of your available memory, as some memory# is also required by the OS to cache rows. Even if you're not using# MyISAM tables, you should still set it to 8-64M as it will also be# used for internal temporary disk tables.在MyISAM表里用于缓存索引块。不要把它设置为大于你的可用内存的30%,因为一些内存还需要由OS缓存行,即使您没有使用MyISAM表,您仍然应该将其设置为8 - 64 m,因为它也会用于内部临时磁盘表key_buffer_size=8M# Size of the buffer used for doing full table scans of MyISAM tables.# Allocated per thread, if a full scan is needed.MyISAM表用来做全表扫描的缓冲区大小

如果需要一个完整的扫描,就分配给每一个线程read_buffer_size=64Kread_rnd_buffer_size=256K# This buffer is allocated when MySQL needs to rebuild the index in# REPAIR, OPTIMZE, ALTER table statements as well as in LOAD DATA INFILE# into an empty table. It is allocated per thread so be careful with# large settings.这个缓冲区是分配给:当MYSQL在需要修理,OPTIMZE,修改表结构语句以及导入加载数据

到一个空表时重建索引。它是分配给每个线程,所以在大型设置中要小心使用。sort_buffer_size=256K#*** INNODB Specific options ***

INNODB特殊项INNODB保存数据目录innodb_data_home_dir="E:/MySQL Datafiles/"# Use this option if you have a MySQL server with InnoDB support enabled# but you do not plan to use it. This will save memory and disk space# and speed up some things.#skip-innodb# Additional memory pool that is used by InnoDB to store metadata# information.  If InnoDB requires more memory for this purpose it will# start to allocate it from the OS.  As this is fast enough on most# recent operating systems, you normally do not need to change this# value. SHOW INNODB STATUS will display the current amount used.InnoDB存储元数据信息时的额外的内存池。如果需要更多的内存,InnoDB为此它会分配它的操作系统内存。因为在大多数操作系统中,这已经是足够快的了,所以通常不需要修改这个值。SHOW INNODB STATUS会显示当前的使用量innodb_additional_mem_pool_size=2M# If set to 1, InnoDB will flush (fsync) the transaction logs to the# disk at each commit, which offers full ACID behavior. If you are# willing to compromise this safety, and you are running small# transactions, you may set this to 0 or 2 to reduce disk I/O to the# logs. Value 0 means that the log is only written to the log file and# the log file flushed to disk approximately once per second. Value 2# means the log is written to the log file at each commit, but the log# file is only flushed to disk approximately once per second.如果设置为1,InnoDB会在每个提交磁盘冲洗事务日志,这提供了完整的ACID的行为.

如果你想安全,并且正在执行一些小操作,你可以设置为0或者2在减少磁盘I / O日志。#innodb_flush_log_at_trx_commit=1# The size of the buffer InnoDB uses for buffering log data. As soon as# it is full, InnoDB will have to flush it to disk. As it is flushed# once per second anyway, it does not make sense to have it very large# (even with long transactions).这个大小用于缓冲InnoDB在缓冲日志数据。一旦它满了,InnoDB会在磁盘上释放它。

它无论如何都会一秒缓冲一次,这对于非常大的日志是没有意义的。(即使有长事务)innodb_log_buffer_size=1M# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and# row data. The bigger you set this the less disk I/O is needed to# access data in tables. On a dedicated database server you may set this# parameter up to 80% of the machine physical memory size. Do not set it# too large, though, because competition of the physical memory may# cause paging in the operating system.  Note that on 32bit systems you# might be limited to 2-3.5G of user level memory per process, so do not# set it too high.InnoDB,不像MyISAM,使用一个缓冲池来缓存的两个索引和行数据。这个磁盘I / O设置的更大,需要访问的数据表更少。在专用的数据库服务器上你可以设置参数高达80%的机器的物理内存大小。不用把它设置的太大,不过,因为在操作系统中竞争的物理内存可能导致内存不够分。注意,32位系统上的你可能被限制在2 - 3.5g的用户级内存,所以不要设置的太高。innodb_buffer_pool_size=83M# Size of each log file in a log group. You should set the combined size# of log files to about 25%-100% of your buffer pool size to avoid# unneeded buffer pool flush activity on log file overwrite. However,# note that a larger logfile size will increase the time needed for the# recovery process.每个日志文件在日志组里的大小。你应该将日志文件大约为25% - -100%缓冲池大小合并来避免不必要的缓冲池的缓冲行为覆盖日志文件。然而,一个大的日志文件将增加复苏过程的所需时间。innodb_log_file_size=17M# Number of threads allowed inside the InnoDB kernel. The optimal value# depends highly on the application, hardware as well as the OS# scheduler properties. A too high value may lead to thread thrashing.InnoDB的内核允许多线程。最高性能取决于高的应用程序、硬件以及操作系统。

一个很高的值可能导致线程抖动innodb_thread_concurrency=8总结:Mysql数据库,分INNODB和MYISAM存储引擎,MYISAM不支持多线程,也就是说,当有一个链接在对某表进行存储操作的时候,会自动锁表。当这个链接操作完成以后,后面的链接才能继续执行存储操作。而INNODB支持多线程,只要不是自己手动锁表,都不是出现类似MYISAM的情况。然后再查询速度上,比如:select count(*) from table1;,MYISAM要强于INNODB,因为,在表数据存进来的时候,MYISAM的引擎就会自动存储一个该表的总数量等信息,那么查询的时候就会自动从那里取得。一般MYISAM在统计数据时用的比较多,差不多了,我所知有限,如果有错误的地方,请各位提出来。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

mysql my.ini 日志_浅析Mysql的my.ini文件 的相关文章

  • mySQL MATCH 跨多个表

    我有一组 4 个表 我想对其进行搜索 每个都有全文索引 查询可以使用每个索引吗 CREATE TABLE categories id int 5 unsigned NOT NULL auto increment display order
  • PHP 选择后立即删除

    我有一个 PHP 服务器脚本 它从 MySQL 数据库中选择一些数据 一旦我将 mysql query 和 mysql fetch assoc 的结果存储在我自己的局部变量中 我就想删除我刚刚选择的行 这种方法的问题在于 PHP 似乎对我的
  • 将记录分成两列

    我的数据库中有一个 学生 表 其中包含大约 5 000 条记录 我想将这些记录显示在two分区 如何在不执行查询两次的情况下做到这一点 仅使用单个查询 显示示例http www freeimagehosting net uploads f1
  • 社交应用程序的数据库设计和优化注意事项

    通常的情况 我有一个简单的应用程序 允许人们上传照片并关注其他人 因此 每个用户都会有类似 墙 或 活动源 的东西 他或她可以在其中看到他 她的朋友 他或她关注的人 上传的最新照片 大多数功能都很容易实现 然而 当涉及到这个历史活动源时 由
  • MYSQL - 查找最近的前一天

    我可以以某种方式 不使用 PHP 找到一周中最近的前一天日期吗 Like 最近的上一个星期二的日期是哪一天 CURDATE INTERVAL WEEKDAY CURDATE wday IF WEEKDAY CURDATE gt wday 0
  • java mysql 准备好的语句

    我正在尝试使用 java 向数据库中进行简单的插入 它告诉我我的 sql 语法已关闭 但是 当我复制打印出来的字符串并将其放入 phpmyadmin 中的 sql 命令中时 它会正确执行该命令 并且我似乎无法弄清楚 java 中的字符串查询
  • 截断 Mysql 表 Cron 作业?

    我在如何使用 cron 作业截断 Mysql 表时遇到了一些麻烦 无论我尝试什么 我似乎都无法让数据库清除表格 感谢您的帮助 mysql uderp example pexample hlocalhost Dexample e TRUNCA
  • 阻止注销页面后的后退按钮

    我有 php 注销页面 当用户单击注销链接时 请参阅此页面并重定向到索引页面 但是当单击后退按钮时 我会看到带有用户数据的上一页 当然 当我刷新页面时 我看不到以前的页面和数据 我在单击注销并单击后退按钮后检查了其他代码 drupal 但我
  • 第三个下拉菜单不从数据库填充

    我有以下 Index php
  • 如何正确转义mysql?

    我刚刚发现如果我写 select from tbl where name like foo 然后添加 foo 作为参数及其值 a 用户数据 它不会正确转义 我勒个去 它想要 a 即使我使用参数 我还是忍不住觉得我对 sql 注入持开放态度
  • MySQL PHP邮政编码比较具体距离

    我试图找出比较一个邮政编码 用户提供的 和一大堆其他邮政编码 现在大约有 200 个邮政编码 之间的距离的最有效方法 相对于加载时间 但它会随着时间的推移而增加 我不需要任何精确的东西 只是在球场上 我下载了整个美国的邮政编码 csv 文件
  • Laravel leftJoin 仅右表的最后一条记录

    我是 Laravel 的新手 我有两张桌子 1 产品 2 价格 products id product int p key name varchar prices id price int p key id product int
  • MySQL 按重复项从上到下排序

    我有一个lammer问题 因为我不是mysql专业人士 我有类似的字段 id color 1 red 2 green 3 yellow 4 green 5 green 6 red 我想按重复项进行分组 最常见的重复项先进行分组 所以应该这样
  • 免费 PHP 登录库 [关闭]

    就目前情况而言 这个问题不太适合我们的问答形式 我们希望答案得到事实 参考资料或专业知识的支持 但这个问题可能会引发辩论 争论 民意调查或扩展讨论 如果您觉得这个问题可以改进并可能重新开放 访问帮助中心 help reopen questi
  • Mysql 将 int 转换为 MAC

    我有一些数据可以转换 其中有 2 列 其中一列有 IP 它包含整数值 我在 mysql 查询中使用了以下函数 是否有一个函数可以用来转换我的 mac 列 其中包含整数和数据类型是bigint to MAC地址 SELECT INET NTO
  • Flask-login:无法理解它是如何工作的

    我试图理解如何Flask Login https flask login readthedocs org en latest works 我在他们的文档中看到他们使用预先填充的用户列表 我想使用数据库存储的用户列表 但是 我不明白其中的一些
  • MySQL 查询到 CSV [重复]

    这个问题在这里已经有答案了 有没有一种简单的方法来运行MySQL查询来自linux命令行并以csv格式输出结果 这就是我现在正在做的事情 mysql u uid ppwd D dbname lt lt EOQ sed e s g tee l
  • 如何使用 Perl 更改 mysql 密码

    我需要使用 Perl 脚本更改一些 mysql 密码 以下内容在更改数据库条目时有效 但是当我针对 mysql 用户更改修改它时 它将它们重置为空白密码 最后 刷新权限 也很好 但我还没有找到方法 usr bin perl use DBI
  • Bugzilla 中分离客户端的基本权限

    我正在尝试配置一个 Bugzilla 实例 这将允许我的客户登录并为其正在开发 维护的网站提交错误 例如 我创建了 2 个名为 TestProject TestProject2 的产品和一个名为 TestClient 的用户 我想要实现的是
  • 如何修改现有表以添加时区

    我有一个包含 500 多个表的大型应用程序 我必须将应用程序转换为时区感知 当前应用程序使用new java util Date GETDATE 与服务器的时区 即没有任何时区支持 我已将这项任务分为几个步骤 以便于开发 我确定的第一个步骤

随机推荐