mysql source 命令导入大的sql文件的方法
(编辑:jimmy 日期: 2024/11/26 浏览:3 次 )
在mysql的安装目录下 找到 my.ini文件 加入以下代码:
interactive_timeout = 120
wait_timeout = 120
max_allowed_packet = 32M
======================================
小例子
mytest_emp_dept.sql文件,内容如下:
CREATE TABLE emp(eid INT PRIMARY KEY AUTO_INCREMENT, ename VARCHAR(20) NOT NULL, esex VARCHAR(10), deptid INT NOT NULL);
CREATE TABLE dept(deptid INT PRIMARY KEY AUTO_INCREMENT, dname VARCHAR(20) NOT NULL,daddress VARCHAR(200));
INSERT INTO emp(ename,esex,deptid) VALUES('chris','M',1),('edge','M',1),('kelly','W',2),('maryse','W',2);
INSERT INTO dept(dname,daddress) VALUES('development','beijing'),('accounting','shanghai');
SELECT ename,esex,dname,daddress FROM emp,dept WHERE emp.deptid=dept.deptid ORDER BY ename;
======================================
导入sql的命令行如下:
source "路径名"+/mytest_emp_dept.sql
======================================
效果如下:
interactive_timeout = 120
wait_timeout = 120
max_allowed_packet = 32M
======================================
小例子
mytest_emp_dept.sql文件,内容如下:
CREATE TABLE emp(eid INT PRIMARY KEY AUTO_INCREMENT, ename VARCHAR(20) NOT NULL, esex VARCHAR(10), deptid INT NOT NULL);
CREATE TABLE dept(deptid INT PRIMARY KEY AUTO_INCREMENT, dname VARCHAR(20) NOT NULL,daddress VARCHAR(200));
INSERT INTO emp(ename,esex,deptid) VALUES('chris','M',1),('edge','M',1),('kelly','W',2),('maryse','W',2);
INSERT INTO dept(dname,daddress) VALUES('development','beijing'),('accounting','shanghai');
SELECT ename,esex,dname,daddress FROM emp,dept WHERE emp.deptid=dept.deptid ORDER BY ename;
======================================
导入sql的命令行如下:
source "路径名"+/mytest_emp_dept.sql
======================================
效果如下:
下一篇:强制修改mysql的root密码的六种方法分享(mysql忘记密码)