MySQL prerequisites
Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

MySQL prerequisites


1. Before You Begin

  • Important: Perform these steps before creating the database.

  • Note: Restart MySQL after making any changes to my.cnf.


2. Locate and Edit my.cnf

  • The my.cnf file is usually found in your MySQL directory.


3. Configuration Settings

A. Settings to Add Above [mysqld] Section

These settings apply to the MySQL client:

[client] default-character-set=utf8mb4

B. Settings to Add Under [mysqld] Section

These settings configure the MySQL server:

[mysqld] character-set-server=utf8mb4 collation-server=utf8mb4_unicode_ci init_connect='SET NAMES utf8mb4' init_connect='SET collation_connection = utf8mb4_unicode_ci' lower_case_table_names=1 innodb_buffer_pool_size=2048M log_bin_trust_function_creators=1 optimizer_search_depth=0 skip-character-set-client-handshake

Note:

  • The value of innodb_buffer_pool_size can be set to 50% of available RAM if the database server is dedicated (no other apps running).

  • Remove skip-character-set-client-handshake for MySQL 8 to avoid collation errors in mysqldump.


4. Restart MySQL Service

Ubuntu

service mysql restart

RedHat / CentOS

systemctl restart mysqld

5. Verify Configuration

  1. Connect to MySQL

  2. Run:

    show variables like '%char%';
    • Confirm that all variables are set to the correct values.

  3. Repeat for all variables as needed.


Additional Notes

  • Character Encoding:
    Setting utf8mb4 ensures support for a wide range of characters.

  • Case Sensitivity:
    lower_case_table_names=1 makes table/database names case-insensitive (recommended for Linux).

  • Collation:
    utf8mb4_unicode_ci supports most Western languages.


Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com