1.sql文件create user sa@'%' identified by '123'
create database pacs;
grant all on pacs.* to sa@'%' identified by '123'
grant all on pacs.* to sa@'localhost' identified by '123'
create user crystal@'%' identified by '456'
create database orcl;
grant all on orcl.* to crystal@'%' identified by '456'
grant all on orcl.* to crystal@'localhost' identified by '456'mysql -u sa -p123 pacs<2.sql
mysql -u crystal -p456 orcl<3.sql 2.sql文件create table test1(
  id int,
  name varchar(12)
);
3.sql文件create table test1(
  id int,
  name varchar(12)
); 怎样把这3个文件合成一个文件运行,请各位看下,谢谢! 

解决方案 »

  1.   

    # mysql -uroot -p12345 dbName < 1.sql
    # mysql -uroot -p12345 dbName < 2.sql
    # mysql -uroot -p12345 dbName < 3.sql
      

  2.   

    你所说的合成一个文件运行是什么意思?
    还有我不知道你所举的sql文件时例子,还是真是的,但是你的文件2和文件3相同,如果按照楼上的方法可能会有问题
      

  3.   

    写到一起,就是一个文件了
    create user sa@'%' identified by '123'
    create database pacs;
    grant all on pacs.* to sa@'%' identified by '123'
    grant all on pacs.* to sa@'localhost' identified by '123'
    create user crystal@'%' identified by '456'
    create database orcl;
    grant all on orcl.* to crystal@'%' identified by '456'
    grant all on orcl.* to crystal@'localhost' identified by '456'create table test1(
      id int,
      name varchar(12)
    );create table test1(
      id int,
      name varchar(12)
    );
    执行mysql -u sa -p123 pacs <1.sql
      

  4.   

    合并到一个sql文件,然后执行mysql -uroot < sql文件。