I am currently working on a Windows application with a MySQL backend. Now I want to copy the old database structure and data to a new database server.
How can I solve this problem using MySQL workbench?
Thank you!
Expand Databases, right-click the desired database, point to Tasks, and then select Copy Database... If the Welcome to the Copy Database Wizard splash page appears, select Next. Select a Source Server page: Specify the server with the database to move or copy.
This is the way with only MySQL Workbech, some times you haven't it installed in new server, like in development to production scenario, in this way you should execute the mysqlimport utility.
Using MySQL Workbench [Migration Wizard]
To directly copy a database from one server to another (even a local one) without creating intermediary export/dump files, you can do so within MySQL Workbench using its Migration Wizard. Go to Database
--> Migration Wizard
.
From there you can select the source and destination connections if you've previously saved them to your Connections list, or you can create a new connection on the fly (be sure to check the box add it to your Connections list).
You'll also choose the database type, or select their generic version (don't remember what it's called) and let it figure out what kind of database servers you have. Generally you can select MySQL for either MySQL or MariaDB databases, as MariaDB is generally designed to be a "binary drop-in replacement" to MySQL.
When it asks you to select which databases, it's my understanding that INFORMATION_SCHEMA
is read only, and should not be selected. Otherwise, unless you have specific needs, probably select all the other tables, if you are, say, cloning the server (and perhaps its related website).
From there you'll let MySQL Workbench do its thing. Keep clicking next while it goes through the process of reverse engineering your schema from the old to the new servers, until it finally copies the data over.
There are many points where you can make changes before proceeding. Also you have the option of viewing potential issues and warnings it notes during the process.
When it's done, you'll still need to add users (manually?) for the cloned database. There is probably an automated way to clone the users table over as well, but I don't know about it. You can do this from the command line if nothing else. Since I use this for my local dev, I only have myself to add anyway.
I'm not sure it's any faster using this tool than exporting and importing the databases in the usual manner. But it's sure easier.
This tool is actually designed for more complex migrations between differing kinds of databases (eg PostgressSQL and MySQL) rather than as a general tool for, say, retrieving a copy of your live database down to your local dev server or vice versa.
Under the same menu, there is Database
-> Schema Transfer Wizard
, which I understood to be used when you need to update to a new server version. I'm not clear specifically the differences between the two tools, or their actual use cases.
Instructions on how to do standard Import / Export operations, in MySQL workbench, the docs are SQL Data Export and Import Wizard, and Table Data Export and Import Wizard.
It would be cool if it were possible to directly import / export between dev and live servers, simply by choosing Connections, rather than saving then reading in dump files.
I think it can be done via the command line though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With