employees
供练习sql使用。mysql同样提供了employees数据库,但并未随数据库一起安装,其下载链接也极其隐蔽,可能导致许多人没注意到。下载地址:https://launchpad.net/test-db/employees-db-1/1.0.6
建议大家下载:employees_db-full-1.0.6.tar.bz2,解压缩,进入目录,并导入。
tar -xjf $HOME/Downloads/employees_db-full-1.0.4.tar.bz2
//解压缩,进入目录
cd employees_db/
//导入数据库root为用户名
mysql -t -u root -p < employees.sql
root@storm-master-01:/home/employees_db#mysql -h ip -t -u username -p password -P3306 < employees.sqlmysql: [Warning] Using a password on the command line interface can be insecure.
+-----------------------------+
| INFO |
+-----------------------------+
| CREATING DATABASE structURE |
+-----------------------------+
+---------------------+
| INFO |
+---------------------+
| LOADING departments |
+---------------------+
+-------------------+
| INFO |
+-------------------+
| LOADING employees |
+-------------------+
ERROR 2006 (HY000) at line 1 in file: 'load_employees.dump': MySQL server has gone away
MySQL max_allowed_packet设置及问题
1、修改mysqld的配置文件my.cnf
调整max_allowed_packet
的值,修改为5M就比较合适了。
[mysqld]
port = 3308
socket = /dev/shm/mysqld.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 10M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
2、修改[mysqld]
中的值
[mysqldump]
quick
max_allowed_packet = 10M
By default this is relatively small.
mysql> show global variables like 'max_allowed_packet';
+--------------------+---------+
| Variable_name | Value |
+--------------------+---------+
| max_allowed_packet | 1048576 |
+--------------------+---------+
1 row in set (0.00 sec)
You can increase, for example to 16M with:
mysql> set global max_allowed_packet=1024*1024*16;
mysql> show global variables like 'max_allowed_packet';
+--------------------+----------+
| Variable_name | Value |
+--------------------+----------+
| max_allowed_packet | 16777216 |
+--------------------+----------+
1 row in set (0.00 sec)
附件
create table emp (
empno numeric(4) not null,
ename varchar(10),
job varchar(9),
mgr numeric(4),
hiredate datetime,
sal numeric(7, 2),
comm numeric(7, 2),
deptno numeric(2)
);
insert into emp values (7369, 'SMITH', 'CLERK', 7902, '1980-12-17', 800, null, 20);
insert into emp values (7499, 'ALLEN', 'SALESMAN', 7698, '1981-02-20', 1600, 300, 30);
insert into emp values (7521, 'WARD', 'SALESMAN', 7698, '1981-02-22', 1250, 500, 30);
insert into emp values (7566, 'JONES', 'MANAGER', 7839, '1981-04-02', 2975, null, 20);
insert into emp values (7654, 'MARTIN', 'SALESMAN', 7698, '1981-09-28', 1250, 1400, 30);
insert into emp values (7698, 'BLAKE', 'MANAGER', 7839, '1981-05-01', 2850, null, 30);
insert into emp values (7782, 'CLARK', 'MANAGER', 7839, '1981-06-09', 2450, null, 10);
insert into emp values (7788, 'SCOTT', 'ANALYST', 7566, '1982-12-09', 3000, null, 20);
insert into emp values (7839, 'KING', 'PRESIDENT', null, '1981-11-17', 5000, null, 10);
insert into emp values (7844, 'TURNER', 'SALESMAN', 7698, '1981-09-08', 1500, 0, 30);
insert into emp values (7876, 'ADAMS', 'CLERK', 7788, '1983-01-12', 1100, null, 20);
insert into emp values (7900, 'JAMES', 'CLERK', 7698, '1981-12-03', 950, null, 30);
insert into emp values (7902, 'FORD', 'ANALYST', 7566, '1981-12-03', 3000, null, 20);
insert into emp values (7934, 'MILLER', 'CLERK', 7782, '1982-01-23', 1300, null, 10);
create table dept (
deptno numeric(2),
dname varchar(14),
loc varchar(13)
);
insert into dept values (10, 'ACCOUNTING', 'NEW YORK');
insert into dept values (20, 'RESEARCH', 'DALLAS');
insert into dept values (30, 'SALES', 'CHICAGO');
insert into dept values (40, 'OPERATIONS', 'BOSTON');
create table bonus (
empno numeric(4),
job varchar(9),
sal numeric,
comm numeric
);
create table salgrade (
grade numeric,
losal numeric,
hisal numeric
);
insert into salgrade values (1, 700, 1200);
insert into salgrade values (2, 1201, 1400);
insert into salgrade values (3, 1401, 2000);
insert into salgrade values (4, 2001, 3000);
insert into salgrade values (5, 3001, 9999);
文章最后发布于: 2018-05-30 10:36:48
相关阅读
对于数据库管理员(DBA)来说,保持数据库运行在最佳状态需要具备敏捷,专注,快速反应的能力以及一颗冷静的头脑。数据库几乎是所有应用
初学者,仅供学习交流 Python学习两周时间了,这是我目前编写的比较满意的一个程序,有以下几个方面的经验总结:1.布局管理是可视化编程
PMM (Percona MySQL Monitor) 部署
部署环境说明mysql 10.0.0.201pmm server 10.0.0.200操作系统都是centos 7.x安装PMM安装dockeryum install docker运行dockersyst
本篇文章实现了一个简易的数据库管理系统,水平有限,没有用户界面。。 开发环境为SQL Server 2008. 1 需求分析 系统描述:本题目
MySQL中order by 和 group by 一起使用
select * from (select * from crm_followup order by CreateTime desc) a GROUP BY a.CDID