How to import a sample database to a MySQL database server using MySQL Workbench

How to import a sample database to a MySQL database server using MySQL Workbench

Abstract:In this tutorial, you will learn how to use MySQL Workbench to load a MySQL sample database into a MySQL database server. Afterwards, you will have a sample database to practice and learn MySQL. classicmodels

Step 1. Download the classicmodels sample database

Step 2. Extract the downloaded file to a temporary folder. You can use any folder you want. To keep it simple, we extract it to the C:\temp  folder.

MySQL sample database

Step 3. Start the MySQL Workbench application:Program Files > MySQL > MySQL Workbench 5.2.

Start MySQL Workbench

Step 4. Add a new database connection, clickNew Connection,as shown below:

New connection

Step 5. Set up a new connection: All connection parameters must be entered in this New Connection window. The following information is required:

  • Connection name: The name of the connection. If you are connected to localhost, just type local. If you are connecting to a specific host, use the hostname as the name of the connection to make it clear.
  • Hostname: In this case, 127.0.0.1 is localhost. You can enter the IP address or the name of the database server.
  • Username: The username you use to connect to the MySQL database. In this case, it's therootuser.

You can also choose to provide the following information:

  • Password: The password of the user used to connect to the database.
  • Default mode: the database to connect to. You can leave it blank and select it later using theuse database command.

Set up a new connection

You should click Test Connection to make sure the parameters you provide are correct and then click the OK button to create this new connection. Once completed, you will see a connection window like this:

connect

Step 6. Click Local Database Connection to connect to the MySQL database server. Because we did not provide a password in the previous step, MySQL requires us to enter the password for therootaccount. We enter the password and click on the OK button.

Connect to MySQL server

If you entered your user and password correctly, you will see the following window:

MySQL workbench

Step 7. Open the SQL script by selecting File > Open SQL Script  or pressing the Ctrl+Shift+O keyboard shortcut.

Open SQL script

Step 8. Select the sql script file from the C drive:\temp\mysqlsampledatabase.txt

Select SQL script file

Step 9. To execute the SQL script, click the execute button in the toolbar as shown below:

Execute SQL script

Step 10. Right-click the Schemas panel and click the Refresh All button to refresh the panel. Theclassimodelsdatabase has been successfully imported to the MySQL database server.

refresh

classicmodelsdatabase

In this tutorial, we have shown you how to load a MySQL sample database into a MySQL database server using MySQL Workbench.

Guess you like

Origin blog.csdn.net/2301_78835635/article/details/135036830