2

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

我的.cnf:

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

SQL_MODE

STRICT_ALL_TABLES

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

例如,考虑以下情况:

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,mysql在尝试向列中插入值时不会抛出错误,而是 mysql 会根据列的类型插入默认数据。例如,对于插入值时的日期时间列,mysql 会将日期时间值默认为.NULLNOT NULLNOT NULLNULL0000-00-00 00-00-00

严格模式,从某种意义上说,就像在 PHP 中调高 error_reporting 级别并显示错误一样,这是开发过程中的最佳实践。

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

所以,我想我在找什么,你在开发过程中推荐的配置是什么,为什么?

4

1 回答 1

1

我会推荐以下附加选项:

# 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
于 2012-04-10T15:08:39.317 回答