1.创建work.sql文件,填写以下内容
-- MySQL dump 10.13 Distrib 5.7.43, for Linux (x86_64)
--
-- Host: localhost Database: work
-- ------------------------------------------------------
-- Server version 5.7.43
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Current Database: `work`
--
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `work` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
USE `work`;
--
-- Table structure for table `dept`
--
DROP TABLE IF EXISTS `dept`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dept` (
`deptno` int(11) NOT NULL AUTO_INCREMENT,
`dname` varchar(20) DEFAULT NULL,
`LOCAL` varchar(20) DEFAULT NULL,
PRIMARY KEY (`deptno`)
) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `dept`
--
LOCK TABLES `dept` WRITE;
/*!40000 ALTER TABLE `dept` DISABLE KEYS */;
INSERT INTO `dept` VALUES (10,'会计','纽约'),(20,'研发','北京'),(30,'销售','上海'),(40,'实施','深圳');
/*!40000 ALTER TABLE `dept` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `emp`
--
DROP TABLE IF EXISTS `emp`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp` (
`EMPNO` int(11) NOT NULL AUTO_INCREMENT,
`ENAME` varchar(20) DEFAULT NULL,
`Job` varchar(20) DEFAULT NULL,
`Mgr` int(11) DEFAULT NULL,
`Hiredate` int(11) DEFAULT NULL,
`Sal` decimal(7,2) DEFAULT NULL,
`Comm` decimal(7,2) DEFAULT NULL,
`deptno` int(11) DEFAULT NULL,
PRIMARY KEY (`EMPNO`),
KEY `fk_deptno` (`deptno`),
CONSTRAINT `fk_deptno` FOREIGN KEY (`deptno`) REFERENCES `dept` (`deptno`)
) ENGINE=InnoDB AUTO_INCREMENT=7935 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `emp`
--
LOCK TABLES `emp` WRITE;
/*!40000 ALTER TABLE `emp` DISABLE KEYS */;
INSERT INTO `emp` VALUES (7369,'SMITH','职员',7902,19801217,800.00,NULL,20),(7499,'ALLEN','销售',7698,19820220,1600.00,300.00,30),(7521,'WARD','销售',7698,19810222,1250.00,500.00,30),(7566,'JONES','经理',7839,19810402,2975.00,NULL,20),(7654,'MARTIN','销售',7698,19810928,1250.00,1400.00,30),(7698,'BLANK','经理',7839,19810501,2850.00,NULL,30),(7782,'CLARK','经理',7839,19810609,2450.00,NULL,10),(7788,'SCOTT','分析师',7566,19870419,3000.00,NULL,20),(7839,'KING','总裁',NULL,19811117,5000.00,NULL,10),(7844,'TURNER','销售',7698,19810908,1500.00,0.00,30),(7876,'ADAMS','职员',7788,19870523,1100.00,NULL,20),(7900,'JAMES','职员',7698,19811203,950.00,NULL,30),(7902,'FORD','分析师',7566,19811203,3000.00,NULL,20),(7934,'MILLER','职员',7782,19820123,1200.00,NULL,10);
/*!40000 ALTER TABLE `emp` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `salgrade`
--
DROP TABLE IF EXISTS `salgrade`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `salgrade` (
`grade` int(11) DEFAULT NULL,
`Losal` int(11) DEFAULT NULL,
`Hisal` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `salgrade`
--
LOCK TABLES `salgrade` WRITE;
/*!40000 ALTER TABLE `salgrade` DISABLE KEYS */;
INSERT INTO `salgrade` VALUES (1,700,1200),(2,1201,1400),(3,1401,2000),(4,2001,3000),(5,3001,9999);
/*!40000 ALTER TABLE `salgrade` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2023-09-09 11:02:25
2.连接上MySQL创建库create database work;
3.退出MySQL连接回到命令行输入mysql -uroot -pAdmin@123 work < work.sql
4.再次查看就可以看到表内容结果了。