{"id":25436683,"url":"https://github.com/roman2004de/mysql-collation-converter","last_synced_at":"2026-04-11T03:34:29.590Z","repository":{"id":276104619,"uuid":"928226924","full_name":"Roman2004de/mysql-collation-converter","owner":"Roman2004de","description":"MySQL Collation and Charset Converter Script","archived":false,"fork":false,"pushed_at":"2025-02-06T09:38:58.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-17T08:23:26.631Z","etag":null,"topics":["bash","collation-tools","encoding-tool","malware","mysql"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Roman2004de.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-06T09:28:35.000Z","updated_at":"2025-02-06T09:41:14.000Z","dependencies_parsed_at":"2025-02-06T10:38:14.865Z","dependency_job_id":null,"html_url":"https://github.com/Roman2004de/mysql-collation-converter","commit_stats":null,"previous_names":["roman2004de/mysql-collation-converter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roman2004de%2Fmysql-collation-converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roman2004de%2Fmysql-collation-converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roman2004de%2Fmysql-collation-converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roman2004de%2Fmysql-collation-converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Roman2004de","download_url":"https://codeload.github.com/Roman2004de/mysql-collation-converter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254264766,"owners_count":22041794,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","collation-tools","encoding-tool","malware","mysql"],"created_at":"2025-02-17T08:21:40.177Z","updated_at":"2025-12-30T23:04:58.804Z","avatar_url":"https://github.com/Roman2004de.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MySQL Collation and Charset Converter Script\r\n\r\n## Overview\r\n\r\nThis Bash script automates the process of converting the collation and character set of a MySQL database, including its tables and columns, to a specified target collation. It ensures consistency across the database while handling foreign key constraints properly.\r\n\r\n## Features\r\n\r\n- Converts the database, tables, and columns to the target character set and collation.\r\n- Handles foreign keys by automatically dropping and restoring them before and after modification.\r\n- Processes all tables in the database or only a specific list provided by the user.\r\n- Skips tables and columns that are already in the target collation to avoid unnecessary operations.\r\n- Logs the current charset and collation of each database, table, and column before modifying them.\r\n- Ensures safe execution by checking the MySQL connection before performing changes.\r\n- Configuration\r\n\r\n## Requirements\r\n\r\n- MySQL 5.7+ or MariaDB\r\n- Bash shell (Linux/macOS)\r\n- User must have sufficient MySQL privileges (ALTER TABLE, ALTER DATABASE, SELECT, DROP FOREIGN KEY, etc.)\r\n\r\n## Configuration\r\n\r\nBefore running the script, configure the following variables:\r\n\r\n- DB_USER=\"your_username\"\r\n- DB_PASS=\"your_password\"\r\n- DB_NAME=\"your_database\"\r\n- TARGET_CHARSET=\"utf8mb4\"\r\n- TARGET_COLLATION=\"utf8mb4_unicode_ci\"\r\n\r\n## Usage\r\n\r\nRun the script with one of the following options:\r\n\r\nConvert all tables in the database:\r\n```sh\r\n./mysql-collation-converter.sh --all\r\n```\r\nThis will scan all tables and update only those that need conversion.\r\n\r\nConvert specific tables (comma-separated list)\r\n```sh\r\n./mysql-collation-converter.sh --list table1,table2\r\n```\r\nThis will process only the specified tables.\r\n\r\n## Example Output\r\n\r\n```sh\r\nDatabase: Current charset: utf8, collation: utf8_general_ci\r\nDatabase is already using target charset and collation.\r\nTable 'b_iblock': Current collation: utf8_unicode_ci\r\nUpdating table 'b_iblock' to collation utf8mb4_unicode_ci...\r\nDropping foreign key 'b_iblock_ibfk_1' from table 'b_iblock'...\r\nDropping foreign key 'b_iblock_ibfk_2' from table 'b_iblock'...\r\nUpdating table 'b_iblock'...\r\nRestoring foreign key 'b_iblock_ibfk_1'...\r\nRestoring foreign key 'b_iblock_ibfk_2'...\r\nConversion complete!\r\n```\r\n\r\n## How It Works\r\n\r\n- Checks the MySQL connection before executing any queries.\r\n- Retrieves the current charset and collation of the database, tables, and columns.\r\n- Drops foreign keys from tables before modifying their structure.\r\n- Converts the database, tables, and columns only if their collation differs from the target.\r\n- Restores foreign keys after successful modification.\r\n\r\n## Important Notes\r\n\r\n- Backup your database before running the script, especially when dealing with foreign keys.\r\n- Ensure all applications using the database support the target charset before making changes.\r\n\r\n## License\r\nThis script is released under the MIT License.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froman2004de%2Fmysql-collation-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froman2004de%2Fmysql-collation-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froman2004de%2Fmysql-collation-converter/lists"}