A2-01-04.How to Load Sample Database into MySQL Database Server

转载自:http://www.mysqltutorial.org/how-to-load-sample-database-into-mysql-database-server.aspx

How to Load Sample Database into MySQL Database Server

 

Summaryin this tutorial, you will learn how to load the MySQL sample database into MySQL database server using MySQL Workbench. After the tutorial, you will have classicmodels sample database loaded into MySQL server for practicing and learning MySQL.

Step 1. Download the classicmodels database from the MySQL sample database section.

Step 2. Unzip the downloaded file into a temporary folder.You can use any folder you want. To make it simple we will unzip it to the C: emp  folder as follows.

MySQL sample database

Step 3. Launch MySQL Workbench application from the Program Files > MySQL > MySQL Workbench 5.2 . The newer version of MySQL Workbench is also relevant.

Launch MySQL Workbench

Step 4. To add a new database connection for querying, click New Connection as follows:

New Connection

Step 5. Setup a new connection: you must enter all connection parameters on this Setup New Connection window. The following information is required:

  • Connection name: the name of the connection. If you connect to the localhost , just type local . In case you connect to a specific host, use the host name for the name of the connection to make it clear.
  • Host name: in this case it is 127.0.0.1 i.e., localhost . You can enter either IP address or the name of the database server.
  • Username: the user that you use connect to the MySQL database. In this case it it the root user.

You can also provide the following information optionally:

  • Password: the password of the user that you use to connect to the database.
  • Default Schema: is the database that you want to connect. You can leave it blank and select later using the use database command.

Setup New Connection

You should click on Test Connection to make sure that the parameters you provided are correct, and then click OK button to create a new connection. Once you complete, you will see connections window as follows:

Connection

Step 6. Click the local database connection to connect to MySQL database server. Because we didn’t provide the password in the previous step, MySQL asks us to enter the password for the root account. We enter our password and click OK button.

Connect to MySQL Server

If you enter both user and password correctly, you will see the following window:

MySQL Workbench

Step 7. Open SQL Script by choosing File > Open SQL Script  or press the Ctrl+Shift+O keyboard shortcut.

Open SQL Script

Step 8. Choose SQL Script File by selecting the File C: empmysqlsampledatabase.sql

Choose SQL Script File

Step 10. To execute SQL Script, you click execute button from the toolbar as following:

Execute SQL Script

Step 11. Right click inside the Schemas panel and click Refresh All button to update the panel. The classimodels database is loaded successfully into MySQL database server.

Refresh All

classicmodels database

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

原文地址:https://www.cnblogs.com/zhuntidaoren/p/9511266.html