How to restore bak file in mysql workbench

MySQL Workbench 5 is a powerful visual tool for administering your MySQL database. It replaces MySQL's previous GUI tools, such as MySQL Administrator and MySQL Query Browser, allowing you to configure, maintain, and backup your database in one place.

To backup and restore your database using the methods described in this article, you will need to have a copy of MySQL Workbench 5.  You can find a copy in the MySQL download archives.

There is a separate guide available that covers how to Back up and restore MySQL databases using MySQL Workbench 6 or 8.

Define your server connection

Before you begin you need to define a connection to the database server.

Step 1

Open MySQL Workbench and click New Server Instance on the right of the window.

Step 2

The Create New Server Instance Profile window will appear. Select Remote Host, enter the IP address of your database server in the Address text field, and click Next.

Step 3

On this page enter the following details:

  • Connection name: Enter a name to allow you to easily identify the database.
  • Connection method: Ensure Standard [TCP/IP] is selected.
  • Hostname: The IP address of the MySQL database server you have been allocated.
  • Port: 3306.
  • Username: The username of your database owner as chosen during your MySQL setup.
  • Default Schema: Enter the name of your database.

Click Next when you have entered the details.

Step 4

Enter your database password when prompted.

If you select Save password in vault MySQL Workbench will not ask you to enter your password again. You should never use this option on a public or shared computer.

Step 5

MySQL Workbench will test the connection to your database using the details you entered. When the test is complete click Next.

Step 6

Select Do not use remote management and click Next.

Step 7

Enter a name in the Server Instance Name field to help you easily identify this database, and click Finish.

You have successfully set up a server instance, which you can use to administer the server, and a connection which stores the database connection details.

Backup your database

MySQL Workbench can export a backup of your database to a file on your local computer. This is also sometimes referred to as a data dump.

We strongly recommend that you create regular backups of your database so it can be easily and quickly recovered in the unlikely event that your data is lost or becomes corrupted.

Step 1

Click Manage Import / Export under Server Administration on the right of the Workbench window. If you can't see this option, make sure the Home tab is selected.

Step 2

Select your database and click OK.

Step 3

Enter your database password if prompted.

Step 4

Select the Export to Disk tab.

Step 5

In the Select Database Objects to Export section, select your database by checking the relevant box in the Export column.

Step 6

Select the tables you wish to export. Click Select All Tables if you would like to export the contents of your entire database.

Step 7

Choose where you would like to save your database backup. There are two options available:

  • Export to Dump Project Folder: MySQL Workbench will create a separate backup file for each table in your database, which will make it possible to store selected tables in the future without the need to restore the entire database.
  • Export to Self-Contained File: All selected tables will be exported to one single SQL file.

Select a location to save your backup.

Step 8

Click Start Export and enter the database password if prompted.

Restore your database from a previous backup

Step 1

Click Manage Import / Export under Server Administration on the right of the Workbench window. If you cannot see this option, make sure the Home tab is selected.

Step 2

Select your database and click OK.

Step 3

Enter your database password if prompted.

Step 4

Select the Import from Disk tab.

Step 5

When you created the backup you were presented with the option to export your database tables to a folder or a single self-contained file. This step will differ depending on which option you chose.

Import from Dump Project Folder

Select Import from Dump Project Folder and enter the location in the Folder Path text field. Click Load Folder Contents.

Select which tables from the backup you would like to restore.

Import from Self-Contained File

Select Import from Self-Contained File and enter the location in the File Path text field.

Step 6

Click Start Import and enter the database password if prompted. This process may take several minutes depending on the size of your database backup.

How do I restore a MySQL database from a BAK file?

Windows Server.
Open a command prompt..
Go to the MySQL bin folder, cd "C:\Program Files\MySQL\MySQL Server 5.6\bin" or. "C:\Program Files\MySQL\MySQL Server 5.7\bin".
Restore the database. Execute: mysql -u whd -p whd < C:\whdbackup.sql..
Enter the whd database user password if prompted for a database password..

How do I restore a BAK file?

Restore the database from a BAK file Right-click on the database server in the left navigation pane, click Tasks, click Restore. The name of the restoring database appears in the To database list box. To create a new database, enter its name in the list box. Select 'From device'.

How do I restore a workspace in MySQL workbench?

Right-click on the MySQL Connections pane and select "Open Connection" from the right-click menu. Left click on the MySQL Connections pane as normal. All the old tabs are restored. Important: When you reopen MySQL workbench later this same process may need to be followed.

Bài mới nhất

Chủ Đề