How to move a MariaDB table to another database;

15 April,2021 by Jack Vamvas

There are some different approaches to moving tables between MariaDB database

Method 1: Move a table to another database - 

This will actually move the table

alter table mig_test.testtbl rename mig_test1.testtb1;

 

Method 2: Entire Database 

Assumed the permissions on source and target database plus underlying file permissions for the dump files are sufficient

--step 1 - dump out the data onto a local file. Ensure you have permissions on the target folder. Note use of mysqldump 

mysqldump -u root databasename_source > dump.sql

--step 2 - import the data from the local file onto the target database. Note use of mysql command

mysql -u root databasename_target < dump.sql

 

Read more on MariaDB commands


Author: Jack Vamvas (http://www.dba-ninja.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to move a MariaDB table to another database;


dba-ninja.com