shepster
shepster

Reputation: 509

How Can I Duplicate a Schema/Database in DBeaver?

I am on a Mac (macOS Monterey 12.6.1) using DBeaver 22.2.4 accessing an AWS Aurora MySQL 5.7 database. During the following process, I am using the MySQL 5.7.39 local client (/usr/local/Cellar/[email protected]/5.7.39).

I would like to duplicate a schema in the database and am trying the Dump Database / Restore Database functionality in DBeaver.

I can use the Dump to create a file (dump-confluence_qa_713-202212141823.sql) on my Mac. I then need to create a new schema to restore to:

CREATE DATABASE confluence_qa_719_dbeaver CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
GRANT ALL PRIVILEGES ON confluence_qa_719_dbeaver.* TO 'confluenceuser'@'%' IDENTIFIED BY 'password';

And this works fine as well.

When try the Restore Database I get the following warning:

You are about to restore database confluence_qa_719_dbeaver from /Users/shepherd/dump-confluence_qa_713-202212141823.sql

It may corrupt your database. Are you sure?

Perhaps this is because I am restoring to a different target than the original? I click Yes and get a Task execution failed error with the following information

--------------

SET @@SESSION.SQL_LOG_BIN= 0

--------------

Task 'MySQL restore' finished at Thu Dec 15 10:11:43 PST 2022
2022-12-15 10:11:43.138 - IO error: Process failed (exit code = 1). See error log.
2022-12-15 10:11:43.139 - java.io.IOException: Process failed (exit code = 1). See error log.
    at org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolHandler.validateErrorCode(AbstractNativeToolHandler.java:242)
    at org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolHandler.executeProcess(AbstractNativeToolHandler.java:223)
    at org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolHandler.doExecute(AbstractNativeToolHandler.java:262)
    at org.jkiss.dbeaver.ext.mysql.tasks.MySQLNativeToolHandler.doExecute(MySQLNativeToolHandler.java:47)
    at org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolHandler.lambda$0(AbstractNativeToolHandler.java:83)
    at org.jkiss.dbeaver.runtime.RunnableContextDelegate.lambda$0(RunnableContextDelegate.java:39)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)

I'm not sure why the Dump worked but the Restore failed. I'm trying to use root credentials for the database.

My end result is I want a copy of the schema. Perhaps there is a better way of doing it than a Dump / Restore? Or, how can I properly do the Restore function?

Upvotes: 4

Views: 15826

Answers (1)

Saikat
Saikat

Reputation: 16890

Using the data migration feature could be one way to achieve this.

On a high level, it's a three-step process:

  • Step 1: Define the data source
  • Step 2: Define the data transfer target type
  • Step 3: Table mapping

Upvotes: 0

Related Questions