แนวทางปฏิบัติที่ดีที่สุดในการกำหนดค่า Mysql ในการพัฒนา?

ฉันเปิดใช้งานสิ่งต่อไปนี้ระหว่างการพัฒนา:

my.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 จะ ไม่ ส่งข้อผิดพลาดเมื่อพยายามแทรกค่า NULL ลงในคอลัมน์ NOT NULL แต่ mysql จะแทรกข้อมูลเริ่มต้นแทน โดยขึ้นอยู่กับประเภทของคอลัมน์ เช่น. สำหรับคอลัมน์ datetime NOT NULL เมื่อคุณใส่ค่า NULL mysql จะตั้งค่าเริ่มต้นของ datetime เป็น 0000-00-00 00-00-00

ในแง่หนึ่ง โหมดเข้มงวดก็เหมือนกับการเพิ่มระดับการรายงานข้อผิดพลาดและการแสดงข้อผิดพลาดใน PHP ซึ่งเป็นแนวทางปฏิบัติที่ดีที่สุดในระหว่างการพัฒนา

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

ฉันเดาว่าสิ่งที่ฉันกำลังมองหาคืออะไร การกำหนดค่าที่แนะนำของคุณคืออะไรในระหว่างการพัฒนา และเพราะเหตุใด


person Gerard Roche    schedule 10.04.2012    source แหล่งที่มา
comment
มีเหตุผลเฉพาะเจาะจงว่าทำไมคุณต้องเปลี่ยนค่าเริ่มต้นหรือไม่?   -  person Anil Mathew    schedule 10.04.2012
comment
@Anil Mathew ไม่ แต่ตัวอย่างเช่น การตั้งค่า sql_mode เป็น strict สามารถช่วยตรวจจับข้อบกพร่องที่อาจเกิดขึ้นหรือพฤติกรรมที่ไม่ได้ตั้งใจได้ มันเหมือนกับการตั้งค่า display_errors=1 & error_reporting(-1) ใน PHP   -  person Gerard Roche    schedule 10.04.2012


คำตอบ (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
person Stephen Senkomago Musoke    schedule 10.04.2012