mysql-lamp-legacy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MySQL / MariaDB (LAMP Legacy)

MySQL / MariaDB (LAMP 遗留系统)

When to use this skill

何时使用此技能

  • Working on legacy LAMP (Linux, Apache, MySQL, PHP) projects.
  • Maintaining WordPress, Drupal, or older custom PHP apps.
  • Dealing with specific MySQL quirks (backticks, engine types).
  • 处理遗留LAMP(Linux、Apache、MySQL、PHP)项目。
  • 维护WordPress、Drupal或旧版自定义PHP应用。
  • 处理MySQL的特定特性(反引号、存储引擎类型)。

1. Schema Management

1. 架构管理

  • Engine: Ensure
    InnoDB
    is used (not MyISAM).
  • Encoding: Convert/Ensure
    utf8mb4
    (collation
    utf8mb4_unicode_ci
    or
    utf8mb4_0900_ai_ci
    ).
  • Dates: Beware of
    0000-00-00
    dates; enable strict mode if possible (
    NO_ZERO_DATE
    ).
  • 存储引擎:确保使用
    InnoDB
    (而非MyISAM)。
  • 编码:转换/确保使用
    utf8mb4
    (排序规则为
    utf8mb4_unicode_ci
    utf8mb4_0900_ai_ci
    )。
  • 日期:注意
    0000-00-00
    格式的日期;如果可能,启用严格模式(
    NO_ZERO_DATE
    )。

2. Identifiers

2. 标识符处理

  • Quoting: Use backticks ` ` for identifiers (tables, columns) if they conflict with keywords.
  • Case Sensitivity: Remember table names are case-sensitive on Linux but not Windows/macOS. Lowercase conventions prefered.
  • 引用:如果标识符(表、列)与关键字冲突,使用反引号` `包裹。
  • 大小写敏感性:记住在Linux系统中表名区分大小写,但在Windows/macOS中不区分。推荐使用小写命名规范。

3. Optimization

3. 优化

  • Indexes: Max key length limits might apply on older versions with
    utf8mb4
    .
  • Query Cache: Deprecated/Removed in newer MySQL; do not rely on it.
  • Foreign Keys: Often missing in legacy apps; add them if
    InnoDB
    allows, otherwise enforce in app logic (but add a comment
    // Logic FK
    ).
  • 索引:在旧版本中使用
    utf8mb4
    时,可能会遇到最大键长度限制。
  • 查询缓存:在新版MySQL中已被弃用/移除;不要依赖它。
  • 外键:遗留应用中通常缺失;如果
    InnoDB
    支持,添加外键;否则在应用逻辑中强制执行(但需添加注释
    // Logic FK
    )。