Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could I use UTF-8 as default character set for MySQL or others? #2008

Closed
parkjaeil0x01 opened this issue May 9, 2024 · 3 comments
Closed

Comments

@parkjaeil0x01
Copy link

Recently, I had to display Korean or other languages in the console output.

However, when the Ansible playbook was first executed and displayed on the semaphore, Korean was displayed normally, but when the playbook execution was completed and the saved record was reopened, Korean was displayed as '?' I found an issue where the text was all garbled.

image

To solve this, I checked the DB character set of my MySQL and confirmed that the default character set is as follows.

SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME
FROM information_schema.SCHEMATA
WHERE SCHEMA_NAME = 'semaphore_db';
[
  {
    "DEFAULT_CHARACTER_SET_NAME": "latin1",
    "DEFAULT_COLLATION_NAME": "latin1_swedish_ci"
  }
]

Now, to change it to UTF-8, I ran the following query:

USE semaphore_db;

-- Generate ALTER TABLE statements for each table in the database
SELECT CONCAT('ALTER TABLE ', table_name, ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;')
FROM information_schema.tables
WHERE table_schema = 'semaphore_db';

-- Execute each generated ALTER TABLE statement to change the character set of existing tables to utf8

-- Step 2: Set default character set for semaphore_db to utf8
ALTER DATABASE semaphore_db CHARACTER SET utf8 COLLATE utf8_unicode_ci;

-- Set default character set for newly created tables in semaphore_db to utf8
ALTER DATABASE semaphore_db DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

And I ran a new task and expected Korean output, but Korean characters are still displayed as '?' in the data saved after printing.

Is there any way to fix this?

@tboerger
Copy link
Collaborator

Semaphore doesn't really care about the database creation, this is up to your setup of the database server.

Just initialize it with the right collation and it should work without any issue.

@parkjaeil0x01
Copy link
Author

Semaphore doesn't really care about the database creation, this is up to your setup of the database server.

Just initialize it with the right collation and it should work without any issue.

Thank you, sir

I'll try it again.

Have a great day :)

@tboerger
Copy link
Collaborator

Closing it for now as the admin need to set the right collation and character set, not semaphore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants