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
Summary: in 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:\temp
folder as follows.
Step 3. Launch MySQL Workbench application from the Program Files > MySQL > MySQL Workbench 5.2
. The newer version of MySQL Workbench is also relevant.
Step 4. To add a new database connection for querying, click New Connection
as follows:
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 typelocal
. 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.
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:
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.
If you enter both user and password correctly, you will see the following window:
Step 7. Open SQL Script by choosing File > Open SQL Script
or press the Ctrl+Shift+O
keyboard shortcut.
Step 8. Choose SQL Script File by selecting the File C:\temp\mysqlsampledatabase.sql
Step 10. To execute SQL Script, you click execute
button from the toolbar as following:
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.
In this tutorial, we have shown you step by step how to load the MySQL sample database into MySQL database server using MySQL Workbench.