Summary: in this tutorial, you will learn how to load the sample database into your MySQL Server using the mysql
program.
Step 1
Download the classicmodels
database from the MySQL sample database section.
Step 2
Unzip the downloaded file into a temporary directory. You can use any directory you prefer, for example, C:\temp
directory.
If you use another operating system such as macOS, Linux, or Unix, please feel free to unzip it to any directory you prefer.
Step 3
Connect to the MySQL server using the mysql
client program:
mysql -u root -p
Code language: SQL (Structured Query Language) (sql)
In this command:
mysql
: This is the command to start the MySQL client, which allows you to connect to interact with databases.-u root
: This specifies the user that you want to connect to the MySQL database server. In this case, it is theroot
user that has full administrative privileges.-p
: This flag will prompt you to enter the password for theroot
user after you execute the command.
You’ll be asked to enter the password for the root
user. Note that the password for the root
user is the one that you set when you installed MySQL.
Enter password: ********
After a successful login, you’ll see the prompt that looks like this:
mysql>
Step 4
Use the source
command to load data into the MySQL Server:
source c:/temp/mysqlsampledatabase.sql
Code language: SQL (Structured Query Language) (sql)
Step 5
Use the SHOW DATABASES
command to list all databases in the current server:
show databases;
Code language: SQL (Structured Query Language) (sql)
The output will look like the following including the newly created classicmodels
database:
+--------------------+
| Database |
+--------------------+
| classicmodels |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
Here’s the video that shows the step by step of how to load the sample database into the MySQL server:
In this tutorial, you have learned step by step how to load the sample database into MySQL server using the mysql
tool.