Mysql示例库安装方法
下载示例库:
https://dev.mysql.com/doc/index-other.html
下载完成后上传到服务器的任意目录,在此示例目录为:
根目录下的/software文件夹。
进入目录后解压缩:
#cd /software/
#unzip test_db-master.zip
解压后会得到一个test_db-master目录,进入该目录
#cd test_db-master
执行导入:
#mysql -h localhost -t <employees.sql -u root -p
输入root用户密码:
注意:如果在导入语句中输入数据库用户密码,会提示
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1049 (42000): Unknown database ‘employees.sql’
导入完后登录到数据库验证:
#mysql -uroot -p
输入root密码:
mysql> show databases;
±-------------------+
| Database |
±-------------------+
| db_mysql |
| employees |
| information_schema |
| mysql |
| performance_schema |
| sys |
±-------------------+
6 rows in set (0.06 sec)
看到employees库已创建完成,进入employees数据库查看表。
mysql> use employees;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
查看库里的表:
mysql> show tables;
±---------------------+
| Tables_in_employees |
±---------------------+
| current_dept_emp |
| departments |
| dept_emp |
| dept_emp_latest_date |
| dept_manager |
| employees |
| salaries |
| titles |
±---------------------+
8 rows in set (0.00 sec)
至此,完成实例库的安装。