How to import third-party MySQL database into LayerStack Managed Database

2024-05-06 By Nathan 40 Views linux database mysql
0 reviews

This guide outlines the process of migrating your third-party cloud database to LayerStack, ensuring minimal disruption to your source database applications. LayerStack's Managed Databases for MySQL provide cost savings, simplified management and backups, scheduled updates, rapid scalability, seamless monitoring, and automated failover to replica nodes in the event of database failures.


You have the option to migrate your existing MySQL database to a LayerStack Managed Database for MySQL using either the mysqldump command line tool or MySQL Workbench, which offers a graphical migration process.


Using mysqldump command


mysqldump is a command-line utility in MySQL used to export databases or specific database objects (like tables) as SQL statements. These SQL statements can then be used to recreate the database or objects elsewhere. mysqldump is particularly useful for backup purposes, database migration, or transferring a database from one server to another.


# mysqldump -h [remotehost] -P [port] -u [username] -p [database-name] > [backup file name]


Assuming the databases you have imported from the third-party service to your instances, you may please follow the below steps to import the databases to LayerStack Managed Database instance.


  1. By default there will be no databases created in the Managed Database instance, therefore, it requires to create database. Follow the command format for logging into the Managed Database.

    # mysql -h <dbhost> -P [port-number]-u lsadmin -p
    


  1. This will prompt your DB password, enter it and you will be able to log in to MySQL terminal of instance.

    importmysql21

  2. Create a new database, in the below example we have created database lstestDB.

    mysql> CREATE DATBASE <db-name>
    

    importmysql2

  3. After creating the database, exit the Managed Database by using exit command.

  4. Import the existing database to the newly created database.

    # mysql -u lsadmin -p -h <dbhost> -P <port-number> your_database_name < /path/to/database_file_name.sql
    


    By using the format, it will prompt the database password, on giving it will import the database successfully. When no error in the process, you will get the below screenshot response.

    importmysql3

  5. To verify if you have done this correctly, log in to the Managed database and check the database tables if they have been properly imported.

    mysql> use database <db-name>
    


    Once the database has been selected , you can check the tables if they are present.

    mysql> show tables;
    

    importmysql4


Migrating with MySQL Workbench


  1. Download and open the MySQL Workbench application.

  2. Select the Migration option located in the left navigation bar within the main Application window.

    importmysql5

  3. At the Overview section, click Start Migration.

    importmysql6

  4. Within the Parameters section, enter your source/third-party database's hostname/IP address in the Hostname, Port, Username and Password section. The Password can be entered in the store in vault option and can use the Test Connection option to test the connection.

    importmysql7

  5. Click Next to save your source database settings.

  6. On the Target Selection step, keep Standard (TCP/IP) as the connection method.

    importmysql8

  7. Enter your LayerStack managed database's hostname/IP address in the Hostname, Port, Username and Password section. You can use the Test Connection option to test the connection.

  8. Select all databases (schemata) you intend to migrate. To choose all, click the select all option in the bottom right corner.

    importmysql9

  9. Proceed by clicking Next to initiate the process of reverse engineering the selected database schema to align it with the target LayerStack database structure.

    importmysql10

  10. In the Object Migration section, keep all Table, View, and Routine objects selected.

    importmysql11

  11. Click Next to prepare objects from the source database.

  12. When the object conversion is successful, click Next to proceed to the Manual Editing step.

    importmysql12

  13. If no migration errors display, click Next to proceed to the Target Creation Options step.

  14. Ensure that the Create schema in target RDMS option is selected. Within the Options section, check the Keep schemas if they already exist option. Then, proceed by clicking Next to commence the migration process from your source database to the target LayerStack database.

    importmysql13


NOTE: If you encounter a prompt regarding existing tables, click Yes to continue. However, if you receive a warning indicating that schemas like SYS, INFORMATION_SCHEMA, PERFORMANCE_SCHEMA, and MYSQL will be dropped in the target MySQL Server, select "Back" and ensure to check the option to keep existing schemas if they already exist. Alternatively, you can navigate back to the Schema selection step and deselect the sys, information schema, performance schema, and mysql databases to prevent any potential database write warning errors.

  1. When successful, click Next to review the database migration results.

  2. Verify that the schema creation report is successful, click Next to set up data transfer options.

    importmysql14

  3. In the Data Copy section, ensure that Online copy of table data to target RDBMS is selected, then proceed by clicking Next to view the migration report.

    importmysql15

  4. Click Finish to complete the migration process.

    importmysql16

  5. Check the Migration Report to know the details about the migration.

    importmysql17

  6. In order to check if the third-party database is migrated to your LayerStack managed database, connect to the LayerStack Managed database on MySQL Workbench from Connect to Database option and log in by entering hostname/IP address in the Hostname, Port, Username and Password.

    importmysql18

    importmysql19

    importmysql20


Conclusion

This article demonstrates migrating an third-party MySQL database to a LayerStack Managed Database. Depending on the size of your database, you have the option to utilize either command-line or graphical tools to perform the migration seamlessly, ensuring no downtime for the applications relying on your database.


Related tutorials

What do you think about this article?

Rate this article
Need assistance?

Try this guide to receive free bundled services at signup on a new free account.

Sign Up

Your Feedback Is Important

We hope you’ll give the new products and updates a try. If you have an idea for improving our products or want to vote on other user ideas so they get prioritized, please submit your feedback on our Community platform. And if you have any questions, please feel free to ask in the Community or contact our Technical Support team.