mysql - 开发中的最佳实践Mysql配置?

标签 mysql development-environment

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

我的.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.

例如,考虑以下内容:

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值时,mysql 不会抛出一个错误到 NOT NULL 列中,mysql 将根据列的类型插入默认数据。例如对于日期时间 NOT NULL 列,当您插入 NULL 值时,mysql 会将日期时间值默认为 0000-00-00 00-00-00.

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

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 - 开发中的最佳实践Mysql配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10090293/

相关文章:

java - JHipster 持久化数据/访问数据库

django - 从 Ubuntu 迁移到 Mac 上的开发环境有多容易(或多难)

asp.net - 理想的开发/测试/质量保证开发环境

python - 在 Windows 上设置 Python 环境

php - Symfony 3 和 Mailhog : mails not being cached by mailhog

Android-Maven 安装时无法执行目标 org.codehaus.mojoto

mysql - AWS Lambda 和 RDS 之间的间歇性超时

php - 从mysql php中的输入框搜索值

php - 8000 字的 mySQL 类型

php - 使用 Twitter 登录是个好主意吗?