Sharing the sample database Sakila Installation Process in MySQL, mysqlsakila
Generally, there is no data available for testing and use on a brand new MySQL server. MySQL provides us with some sample databases for basic operations and stress testing based on these databases. This document describes how to install the sakila database. The database must be installed in MySQL 5.0 or later versions. The following is the description.
1. Download the seed Database
Download location: http://dev.mysql.com/doc/index-other.html
2. Install the seed database sakila
Copy codeThe Code is as follows:
[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. Verify the installation result
Copy codeThe Code is as follows:
[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 |
| Marshal |
| 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 (*) |
+ ---------- +
| 1, 599 |
+ ---------- +
1 row in set (0.01 sec)
In the SAKILA table of the mysql database, how does one display the employee ID with the highest payment?
Select id from SAKILA order by xx limit 0, 1
When mysql queries all the information of the staff table in the sakila database, garbled characters are displayed: select * from staff; this will happen, and the solution is as follows:
For database Encoding Problems, you should first use set names UTF-8/gbk/gb2312. Try such a statement. garbled characters must be caused by a problem in database encoding settings.