最佳实践Mysql配置开发中? [英] Best practice Mysql configuration in development?

查看:70
本文介绍了最佳实践Mysql配置开发中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发过程中启用了以下功能:

I enable the following during development:

my.cnf:

[mysqld]
log_slow_queries    = /var/log/mysql/mysql-slow.log
sql_mode            = STRICT_ALL_TABLES



SQL_MODE



STRICT_ALL_TABLES


为所有存储引擎启用严格模式。无效的数据值被拒绝

Enable strict mode for all storage engines. Invalid data values are rejected.

例如,请考虑以下内容:

For example, consider the following:

CREATE TABLE `posts` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `title` varchar(200) NOT NULL,
    `date` datetime NOT NULL
);
INSERT INTO `posts` (`title`, `date`) VALUES ('Title text', NULL);

如果使用 STRICT_ALL_TABLES sql_mode ,当尝试将 NULL 值插入<$ c $时,mysql将抛出错误c> NOT NULL 列,取而代之的是mysql将根据列的类型插入默认数据。例如对于日期时间 NOT NULL 列,当您插入 NULL 值时,mysql将日期时间值默认为 0000-00-00 00-00-00

If you use STRICT_ALL_TABLES sql_mode, mysql will not throw an error when trying to insert a NULL value into a NOT NULL column, instead mysql will insert default data depending on the type of column. e.g. for a datetime NOT NULL column when you insert a NULL value, mysql will default the datetime value to 0000-00-00 00-00-00.

从某种意义上讲,严格模式就像提高了error_reporting级别并显示PHP中的错误,这是开发过程中的最佳做法。

Strict mode, in a sense, is like turning up the error_reporting level and displaying errors in PHP, which is a best practice during development.

ini_set('error_reporting', -1);
ini_set('display_errors', true);

所以,我猜我在找什么,在此期间您推荐的配置是什么开发以及为什么?

推荐答案

我建议以下其他选项:

# creates a innodb file per table instead of having all the tables in a single tablespace file
innodb_file_per_table 

# increase the max allowed packet to a large size for file imports
max_allowed_packet = 32M

# the InnoDB pool size. use up to 80% available RAM for dedicated machines, and as much
# as you can spare for development machines also depending on the size of the databases
# you will be running so that as much of the database as possible fits into memory 
innodb_buffer_pool_size = 512M

这篇关于最佳实践Mysql配置开发中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆