One solution could be to export the data from both databases into CSV files, then merge the CSV files and import them into a new database. Here are the steps:
- Export the data from the first database into a CSV file. You can do this using the following command in the MySQL command line:
SELECT * INTO OUTFILE '/path/to/file.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' FROM table_name;
Replace /path/to/file.csv with the path where you want to save the CSV file, and table_name with the name of the table you want to export.
-
Repeat step 1 for the second database, saving the CSV file to a different location.
-
Merge the two CSV files into one using a tool like Excel or Google Sheets.
-
Create a new database in MySQL where you want to import the merged data.
-
Import the merged CSV file into the new database using the following command in the MySQL command line:
LOAD DATA INFILE '/path/to/merged_file.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
Replace /path/to/merged_file.csv with the path to the merged CSV file, and table_name with the name of the table you want to import the data into.
Note: This solution assumes that the two databases have the same schema (i.e. same table names and columns). If they don't, you'll need to modify the export and import commands accordingly.