当前位置: 移动技术网 > IT编程>数据库>Mysql > MySQL中安装样本数据库Sakila过程分享

MySQL中安装样本数据库Sakila过程分享

2017年12月12日  | 移动技术网IT编程  | 我要评论

通常情况下对于一个全新的mysql服务器,没有任何数据供我们测试和使用。对此,mysql为我们提供了一些样本数据库,我们可以基于这些数据库作基本的操作以及压力测试等等。本文描述的是安装sakila数据库。该数据库需要安装在mysql 5.0以上的版本。以下是其描述。

1、下载种子数据库

下载位置:

2、安装种子数据库sakila

复制代码 代码如下:

[root@localhost ~]# unzip sakila-db.zip
archive:  sakila-db.zip
   creating: sakila-db/
  inflating: sakila-db/sakila-schema.sql 
  inflating: sakila-db/sakila.mwb   
  inflating: sakila-db/sakila-data.sql
the sakila-schema.sql file contains all the create statements required to create the structure of the sakila database including tables, views, stored procedures, and triggers.
 
the sakila-data.sql file contains the insert statements required to populate the structure created by the sakila-schema.sql file, along with definitions for triggers that must be created after the initial data load.

the sakila.mwb file is a mysql workbench data model that you can open within mysql workbench to examine the database structure. for more information, see mysql workbench.
[root@localhost ~]# ls
anaconda-ks.cfg  desktop  install.log  install.log.syslog  sakila-db  sakila-db.zip
[root@localhost ~]# cd sakila-db
[root@localhost sakila-db]# ls
sakila-data.sql  sakila.mwb  sakila-schema.sql
[root@localhost sakila-db]# mysql -uroot -p <sakila-schema.sql
enter password:
[root@localhost sakila-db]# mysql -uroot -p <sakila-data.sql
enter password:

3、验证安装结果

复制代码 代码如下:

[root@localhost sakila-db]# mysql
root@localhost[(none)]> show databases;
+--------------------+
| database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sakila             |
| scottdb            |
| tempdb             |
| test               |
+--------------------+
7 rows in set (0.01 sec)
root@localhost[(none)]> use sakila
database changed
root@localhost[sakila]> show tables;
+----------------------------+
| tables_in_sakila           |
+----------------------------+
| actor                      |
| actor_info                 |
| address                    |
| category                   |
| city                       |
| country                    |
| customer                   |
| customer_list              |
| film                       |
| film_actor                 |
| film_category              |
| film_list                  |
| film_text                  |
| inventory                  |
| language                   |
| nicer_but_slower_film_list |
| payment                    |
| rental                     |
| sales_by_film_category     |
| sales_by_store             |
| staff                      |
| staff_list                 |
| store                      |
+----------------------------+
23 rows in set (0.00 sec)
root@localhost[sakila]> select count(*) from customer;
+----------+
| count(*) |
+----------+
|      599 |
+----------+
1 row in set (0.01 sec)

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网