How to modify MySQL/MariaDB .sql export file not breaking character/set?

Discussion in 'MySQL' started by postcd, Apr 10, 2025.

  1. #1
    Hello, please how to properly modify MySQL database export file .sql so the character set is not changed/content is not broken after saving/importing the modified file?

    I have opened the file in Linux editor Kate and saved a modified copy of the file with default UTF-8 charset, then uploaded the file to the new database using PHPMyAdmin (while left selected default utf-8 charset of the file) or using BigDump php script. In both cases the charset was likely wrong, since CMS errored, saying that I was likely "importing your database tables using the wrong character set or collation". Importing original/unmodified .sql file (using BidDump which had "$db_connection_charset = 'utf8';" set as in previous case where i have imported a modified .sql file) made the site working. So the problem is likely in a wrong charset used in saving the file or less likely I did some error in editing the file?

    Original .sql export file header:
    /*M!999999- enable the sandbox mode */
    – MariaDB dump 10.19 Distrib 10.6.20-MariaDB, for Linux (x86_64)
    
    – Host: localhost Database: ***
    – Server version 10.6.20-MariaDB-cll-lve
    
    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT /;
    /!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS /;
    /!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION /;
    /!40101 SET NAMES utf8mb4 /;
    /!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE /;
    /!40103 SET TIME_ZONE=‘+00:00’ /;
    /!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 /;
    /!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 /;
    /!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=‘NO_AUTO_VALUE_ON_ZERO’ /;
    /!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
    Code (markup):

    Source DB and imported DBs shows collation latin1_swedish_ci, type MyISAM. Both DBs are on same physical server with 10.6.20-MariaDB-cll-lve, Server charset: cp1252 West European (latin1), Server connection collation: utf8mb4_unicode_ci

    My question is how to modify and save the copy of the file properly in this case, please?
     
    postcd, Apr 10, 2025 IP
  2. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,251
    Likes Received:
    1,690
    Best Answers:
    31
    Trophy Points:
    475
    #2
    You'd be better off asking this on stackoverflow or reddit.
     
    qwikad.com, Apr 10, 2025 IP