sunmingtao / sample-code

3 stars 4 forks source link

Change MySQL default server collation #358

Closed sunmingtao closed 1 month ago

sunmingtao commented 1 month ago

Locate the MySQL Configuration File:

On Linux, it's typically located at /etc/mysql/my.cnf or /etc/my.cnf. On Windows, it's typically located at C:\ProgramData\MySQL\MySQL Server X.X\my.ini or in the MySQL installation directory.

If it doesn't exist, you can create one

Navigate to the MySQL installation directory. e.g. C:\Users\msun\mysql-8.0.30-winx64. Create a new file named my.ini in this directory.

[mysqld]
collation_server = utf8mb4_unicode_ci
character_set_server = utf8mb4

To start the server with the configuration file

cd C:\Users\msun\mysql-8.0.30-winx64\bin
mysqld --defaults-file=C:\Users\msun\mysql-8.0.30-winx64\my.ini --console

SHOW VARIABLES LIKE 'collation_server';