Skip to content

Latest commit

 

History

History
20 lines (16 loc) · 1.05 KB

rds-import-to-local.md

File metadata and controls

20 lines (16 loc) · 1.05 KB

Export mysql data from rds to local mysql

  1. The local database retains the database name, deletes all tables, executes schema sync locally to generate data tables and structures, and clears the default data of all data tables.
  2. Run the resulting statement executed by 'sql' below, remove all the 'table' foreign key dependencies.
SELECT CONCAT('ALTER TABLE ',TABLE_SCHEMA,'.',TABLE_NAME,' DROP FOREIGN KEY ',CONSTRAINT_NAME,' ;')
	FROM information_schema.TABLE_CONSTRAINTS c
		WHERE c.TABLE_SCHEMA='glass' AND c.CONSTRAINT_TYPE='FOREIGN KEY';
SELECT CONCAT('ALTER TABLE ','`',TABLE_NAME,'`',' DROP FOREIGN KEY ',CONSTRAINT_NAME,' ;')
	FROM information_schema.TABLE_CONSTRAINTS c
		WHERE c.TABLE_SCHEMA='glass' AND c.CONSTRAINT_TYPE='FOREIGN KEY';
  1. RDS exports all data tables (data, excludes db structures) of the entire database. Execute the 'db_dump.sql' exported by RDS.
  2. mysql terminal (mysql -uroot -p), run source db_dump.sql
  3. cd local project dev-server, run yarn serve to sync structure to recovery foreign key dependencies.